with('profileLink', $this->profileLink()) ->with('deals', $this->deals()); } protected function deals() { return Deal::query() ->where('active', true) ->select([ 'id', 'title', 'description', 'image', 'active', 'slug', 'link', 'deal_category_id', 'user_id', ]) ->with([ 'category:id,name', 'broker' => function ($query) { $query->select('id', 'name', 'email', 'role_type', 'role_id') ->with('type'); }, ]) ->latest() ->paginate(); } /** * Determines the link to the user's profile dashboard * based on the user's role. * * @return string The URL for the user's dashboard. */ protected function profileLink() { $user = Auth::user(); if ($user->role === UserTypes::Broker->value) { return route('broker.profile.show', $user); } } }