*/ public function getUserFavorites(User $user): Collection { return $this->model ->newQuery() ->where([ 'user_id' => $user->id, 'liked' => true, ]) ->with('song') ->pluck('song'); } /** @return array */ public function getRecentlyPlayed(User $user, ?int $count = null): array { return $this->model ->newQuery() ->where('user_id', $user->id) ->where('play_count', '>', 0) ->latest('last_played_at') ->when($count, static fn (Builder $query, int $count) => $query->take($count)) ->pluck('song_id') ->all(); } }