*/ 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 { $query = $this->model ->newQuery() ->where('user_id', $user->id) ->where('play_count', '>', 0) ->latest('updated_at'); if ($count) { $query = $query->take($count); } return $query->pluck('song_id')->all(); } }