2022-06-10 10:47:46 +00:00
|
|
|
<?php
|
|
|
|
|
2023-06-05 21:46:41 +00:00
|
|
|
namespace App\Http\Requests\API;
|
2022-06-10 10:47:46 +00:00
|
|
|
|
2022-07-27 09:30:04 +00:00
|
|
|
use App\Repositories\SongRepository;
|
2022-06-10 10:47:46 +00:00
|
|
|
use Illuminate\Validation\Rule;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @property-read string|null $sort
|
|
|
|
* @property-read string $order
|
|
|
|
* @property-read int $limit
|
|
|
|
*/
|
2024-01-02 12:07:37 +00:00
|
|
|
class FetchSongsForQueueRequest extends Request
|
2022-06-10 10:47:46 +00:00
|
|
|
{
|
|
|
|
/** @return array<mixed> */
|
|
|
|
public function rules(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'order' => ['required', Rule::in('asc', 'desc', 'rand')],
|
|
|
|
'limit' => 'required|integer|min:1',
|
2022-07-27 09:30:04 +00:00
|
|
|
'sort' => [
|
|
|
|
'required_unless:order,rand',
|
|
|
|
Rule::in(array_keys(SongRepository::SORT_COLUMNS_NORMALIZE_MAP)),
|
|
|
|
],
|
2022-06-10 10:47:46 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|