user(); return ExcerptSearchResult::make( $this->songRepository->getByIds( Song::search($keywords)->get()->take($count)->pluck('id')->all(), $scopedUser ), $this->artistRepository->getByIds( Artist::search($keywords)->get()->take($count)->pluck('id')->all(), $scopedUser ), $this->albumRepository->getByIds( Album::search($keywords)->get()->take($count)->pluck('id')->all(), $scopedUser ), ); } /** @return Collection|array */ public function searchSongs( string $keywords, ?User $scopedUser = null, int $limit = self::DEFAULT_MAX_SONG_RESULT_COUNT ): Collection { return Song::search($keywords) ->query(static function (SongBuilder $builder) use ($scopedUser, $limit): void { $builder->withMeta($scopedUser ?? auth()->user())->limit($limit); }) ->get(); } }