user(); $perPage = 30; // People who follow $user (user_id = $user being followed) $followers = DB::table('user_followers as uf') ->join('users as u', 'u.id', '=', 'uf.follower_id') ->leftJoin('user_profiles as up', 'up.user_id', '=', 'u.id') ->leftJoin('user_statistics as us', 'us.user_id', '=', 'u.id') ->where('uf.user_id', $user->id) ->whereNull('u.deleted_at') ->orderByDesc('uf.created_at') ->select([ 'u.id', 'u.username', 'u.name', 'up.avatar_hash', 'us.uploads_count', 'uf.created_at as followed_at', ]) ->paginate($perPage) ->withQueryString() ->through(fn ($row) => (object) [ 'id' => $row->id, 'username' => $row->username, 'uname' => $row->username ?? $row->name, 'avatar_url' => AvatarUrl::forUser((int) $row->id, $row->avatar_hash, 50), 'profile_url' => '/@' . strtolower((string) ($row->username ?? $row->id)), 'uploads' => $row->uploads_count ?? 0, 'followed_at' => $row->followed_at, ]); return view('dashboard.followers', [ 'followers' => $followers, 'page_title' => 'My Followers', ]); } }