user(); $logs = NotificationLog::query() ->where(function ($query) use ($customer) { $query->where(function ($q) use ($customer) { $q->where('notifiable_type', Job::class) ->whereIn('notifiable_id', $customer->serviceJobs()->select('id')); })->orWhere(function ($q) use ($customer) { $q->where('notifiable_type', Customer::class) ->where('notifiable_id', $customer->id); }); }) ->orderByDesc('created_at') ->paginate(20); return view('portal.notifications.index', compact('logs')); } }