Notifications changes so they are not filtered by user
This commit is contained in:
parent
bdde610178
commit
7d4d18143d
|
|
@ -35,12 +35,7 @@ public function unread(Request $request)
|
||||||
->select(['id', 'due_date', 'amount', 'contract_id', 'client_case_id', 'created_at'])
|
->select(['id', 'due_date', 'amount', 'contract_id', 'client_case_id', 'created_at'])
|
||||||
->whereNotNull('due_date')
|
->whereNotNull('due_date')
|
||||||
->whereDate('due_date', '<=', $today)
|
->whereDate('due_date', '<=', $today)
|
||||||
->whereNotExists(function ($q) use ($user) {
|
// Removed per-user unread filter: show notifications regardless of individual reads
|
||||||
$q->from('activity_notification_reads as anr')
|
|
||||||
->whereColumn('anr.activity_id', 'activities.id')
|
|
||||||
->where('anr.user_id', $user->id)
|
|
||||||
->whereColumn('anr.due_date', 'activities.due_date');
|
|
||||||
})
|
|
||||||
->when($clientCaseIdsForFilter->isNotEmpty(), function ($q) use ($clientCaseIdsForFilter) {
|
->when($clientCaseIdsForFilter->isNotEmpty(), function ($q) use ($clientCaseIdsForFilter) {
|
||||||
// Filter by clients: activities directly on any of the client's cases OR via contracts under those cases
|
// Filter by clients: activities directly on any of the client's cases OR via contracts under those cases
|
||||||
$q->where(function ($qq) use ($clientCaseIdsForFilter) {
|
$q->where(function ($qq) use ($clientCaseIdsForFilter) {
|
||||||
|
|
@ -113,12 +108,7 @@ public function unread(Request $request)
|
||||||
->select(['contract_id', 'client_case_id'])
|
->select(['contract_id', 'client_case_id'])
|
||||||
->whereNotNull('due_date')
|
->whereNotNull('due_date')
|
||||||
->whereDate('due_date', '<=', $today)
|
->whereDate('due_date', '<=', $today)
|
||||||
->whereNotExists(function ($q) use ($user) {
|
// Removed per-user unread filter for client list base
|
||||||
$q->from('activity_notification_reads as anr')
|
|
||||||
->whereColumn('anr.activity_id', 'activities.id')
|
|
||||||
->where('anr.user_id', $user->id)
|
|
||||||
->whereColumn('anr.due_date', 'activities.due_date');
|
|
||||||
})
|
|
||||||
->when($clientCaseIdsForFilter->isNotEmpty(), function ($q) use ($clientCaseIdsForFilter) {
|
->when($clientCaseIdsForFilter->isNotEmpty(), function ($q) use ($clientCaseIdsForFilter) {
|
||||||
$q->where(function ($qq) use ($clientCaseIdsForFilter) {
|
$q->where(function ($qq) use ($clientCaseIdsForFilter) {
|
||||||
$qq->whereIn('activities.client_case_id', $clientCaseIdsForFilter)
|
$qq->whereIn('activities.client_case_id', $clientCaseIdsForFilter)
|
||||||
|
|
|
||||||
|
|
@ -71,12 +71,7 @@ public function share(Request $request): array
|
||||||
$activities = \App\Models\Activity::query()
|
$activities = \App\Models\Activity::query()
|
||||||
->select(['id', 'due_date', 'amount', 'contract_id', 'client_case_id', 'created_at'])
|
->select(['id', 'due_date', 'amount', 'contract_id', 'client_case_id', 'created_at'])
|
||||||
->whereDate('due_date', $today)
|
->whereDate('due_date', $today)
|
||||||
->whereNotExists(function ($q) use ($request) {
|
// Removed per-user unread filter: show notifications regardless of individual reads
|
||||||
$q->from('activity_notification_reads as anr')
|
|
||||||
->whereColumn('anr.activity_id', 'activities.id')
|
|
||||||
->where('anr.user_id', optional($request->user())->id)
|
|
||||||
->whereColumn('anr.due_date', 'activities.due_date');
|
|
||||||
})
|
|
||||||
->orderBy('created_at')
|
->orderBy('created_at')
|
||||||
->limit(20)
|
->limit(20)
|
||||||
->get();
|
->get();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user