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\FetchRandomSongsInGenreRequest;
|
2022-10-21 20:06:43 +00:00
|
|
|
use App\Http\Resources\SongResource;
|
|
|
|
use App\Models\User;
|
|
|
|
use App\Repositories\SongRepository;
|
|
|
|
use Illuminate\Contracts\Auth\Authenticatable;
|
|
|
|
|
|
|
|
class FetchRandomSongsInGenreController extends Controller
|
|
|
|
{
|
|
|
|
/** @param User $user */
|
|
|
|
public function __invoke(
|
|
|
|
FetchRandomSongsInGenreRequest $request,
|
|
|
|
SongRepository $repository,
|
|
|
|
Authenticatable $user
|
|
|
|
) {
|
|
|
|
return SongResource::collection($repository->getRandomByGenre($request->genre, $request->limit, $user));
|
|
|
|
}
|
|
|
|
}
|