currentProject = auth()->user()->currentProject; $this->projects = Project::query() ->where(function (Builder $query) { if (auth()->user()->isAdmin()) { return; } $query->where('user_id', auth()->id()) ->orWhereHas('users', fn ($query) => $query->where('user_id', auth()->id())); }) ->get(); } public function updateProject(Project $project): void { $this->authorize('view', $project); auth()->user()->update(['current_project_id' => $project->id]); $this->redirect('/'); } }