mirror of
https://github.com/koel/koel
synced 2024-12-22 02:23:14 +00:00
33 lines
832 B
PHP
33 lines
832 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\API\GenreFetchSongRequest;
|
|
use App\Http\Resources\SongResource;
|
|
use App\Models\User;
|
|
use App\Repositories\SongRepository;
|
|
use App\Values\Genre;
|
|
use Illuminate\Contracts\Auth\Authenticatable;
|
|
|
|
class GenreSongController extends Controller
|
|
{
|
|
/**
|
|
* @param User $user
|
|
*/
|
|
public function __invoke(
|
|
string $genre,
|
|
SongRepository $repository,
|
|
Authenticatable $user,
|
|
GenreFetchSongRequest $request
|
|
) {
|
|
return SongResource::collection(
|
|
$repository->getByGenre(
|
|
$genre === Genre::NO_GENRE ? '' : $genre,
|
|
$request->sort ?: 'songs.title',
|
|
$request->order ?: 'asc',
|
|
$user
|
|
)
|
|
);
|
|
}
|
|
}
|