koel/app/Http/Controllers/API/GenreSongController.php

34 lines
832 B
PHP
Raw Normal View History

2022-10-21 20:06:43 +00:00
<?php
2023-06-05 21:46:41 +00:00
namespace App\Http\Controllers\API;
2022-10-21 20:06:43 +00:00
use App\Http\Controllers\Controller;
2023-06-05 21:46:41 +00:00
use App\Http\Requests\API\GenreFetchSongRequest;
2022-10-21 20:06:43 +00:00
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,
2022-10-21 20:06:43 +00:00
$request->sort ?: 'songs.title',
$request->order ?: 'asc',
$user
)
);
}
}