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