45 lines
1.6 KiB
PHP
45 lines
1.6 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Modules\Movies\Http\Requests;
|
||
|
|
|
||
|
|
use Illuminate\Foundation\Http\FormRequest;
|
||
|
|
|
||
|
|
class UpdateMovieRequest extends FormRequest
|
||
|
|
{
|
||
|
|
public function authorize(): bool
|
||
|
|
{
|
||
|
|
// Any authenticated user can manage
|
||
|
|
return (bool) $this->user();
|
||
|
|
}
|
||
|
|
|
||
|
|
public function rules(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
// Scalars (all optional)
|
||
|
|
'title' => ['sometimes', 'string', 'min:1'],
|
||
|
|
'original_title' => ['sometimes', 'nullable', 'string'],
|
||
|
|
'description' => ['sometimes', 'nullable', 'string'],
|
||
|
|
'poster_url' => ['sometimes', 'nullable', 'url'],
|
||
|
|
'backdrop_url' => ['sometimes', 'nullable', 'url'],
|
||
|
|
'rating' => ['sometimes', 'nullable', 'string', 'max:20'],
|
||
|
|
'release_date' => ['sometimes', 'nullable', 'date'],
|
||
|
|
'year' => ['sometimes', 'nullable', 'integer', 'min:1800', 'max:3000'],
|
||
|
|
'runtime' => ['sometimes', 'nullable', 'integer', 'min:1', 'max:10000'],
|
||
|
|
|
||
|
|
// Relations via free-text chips (arrays of strings)
|
||
|
|
'genres' => ['sometimes', 'array'],
|
||
|
|
'genres.*' => ['string', 'min:1'],
|
||
|
|
'actors' => ['sometimes', 'array'],
|
||
|
|
'actors.*' => ['string', 'min:1'],
|
||
|
|
'directors' => ['sometimes', 'array'],
|
||
|
|
'directors.*' => ['string', 'min:1'],
|
||
|
|
'studios' => ['sometimes', 'array'],
|
||
|
|
'studios.*' => ['string', 'min:1'],
|
||
|
|
'countries' => ['sometimes', 'array'],
|
||
|
|
'countries.*' => ['string', 'min:1'],
|
||
|
|
'languages' => ['sometimes', 'array'],
|
||
|
|
'languages.*' => ['string', 'min:1'],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|