filled('user_id')) { $query->where('user_id', $request->user_id); } if ($request->filled('module')) { $query->where('module', $request->module); } if ($request->filled('action')) { $query->where('action', $request->action); } if ($request->filled('from')) { $query->whereDate('created_at', '>=', $request->from); } if ($request->filled('to')) { $query->whereDate('created_at', '<=', $request->to); } $logs = $query->orderByDesc('created_at')->paginate(50); $users = User::orderBy('name')->get(); $modules = ActivityLog::select('module')->distinct()->pluck('module'); return view('admin.activity-logs.index', compact('logs', 'users', 'modules')); } }