48 lines
1.5 KiB
PHP
48 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class UpdateVideoRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'title' => 'sometimes|string|max:255',
|
|
'description' => 'sometimes|string|max:3000',
|
|
'url' => 'sometimes|string|max:500',
|
|
'thumbnail' => 'sometimes|file|mimes:jpg,jpeg,png,webp|max:4000',
|
|
'tags' => 'sometimes|string|max:100',
|
|
'category_ids' => 'sometimes|array',
|
|
'category_ids.*' => 'exists:categories,id',
|
|
'is_active' => 'sometimes|boolean',
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'title.max' => 'O título deve ter no máximo 255 caracteres',
|
|
'description.max' => 'A descrição deve ter no máximo 3000 caracteres',
|
|
'url.max' => 'A URL deve ter no máximo 500 caracteres',
|
|
'thumbnail.mimes' => 'O ficheiro deve ser do formato jpg, jpeg, png ou webp',
|
|
'thumbnail.max' => 'A thumbnail deve ter no máximo 4MB',
|
|
'category_id.exists' => 'A categoria não existe',
|
|
];
|
|
}
|
|
}
|