Estado inicial: frontend React + backend Laravel
This commit is contained in:
52
plataforma-tutorias/app/Http/Requests/CreateVideoRequest.php
Normal file
52
plataforma-tutorias/app/Http/Requests/CreateVideoRequest.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateVideoRequest 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' => 'required|string|max:255',
|
||||
'description' => 'required|string|max:3000',
|
||||
'url' => 'required|file|mimes:mp4,mov,avi,wmv,flv,mpeg,mpg,m4v,3gp,3g2,mj2|max:512000', // 500MB
|
||||
'thumbnail' => 'required|image|mimes:jpg,jpeg,png,webp|max:4000',
|
||||
'duration' => 'nullable|string|max:10',
|
||||
'tags' => 'nullable|string|max:255', // nullable para não ser obrigatório
|
||||
'category_ids' => 'nullable|array|exists:categories,id', // nullable caso não selecione
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'title.required' => 'O título é obrigatório',
|
||||
'title.max' => 'O título deve ter no máximo 255 caracteres',
|
||||
'description.required' => 'A descrição é obrigatória',
|
||||
'description.max' => 'A descrição deve ter no máximo 3000 caracteres',
|
||||
'url.required' => 'A URL é obrigatória',
|
||||
'url.mimes' => 'A URL deve ser um arquivo de vídeo',
|
||||
'url.max' => 'A URL deve ter no máximo 500 caracteres',
|
||||
'thumbnail.required' => 'A thumbnail é obrigatória',
|
||||
'thumbnail.mimes' => 'Ficheiro de imagem inválido: deve ser jpg, jpeg, png ou webp',
|
||||
'thumbnail.max' => 'A thumbnail deve ter no máximo 4MB',
|
||||
'tags.max' => 'As tags devem ter no máximo 50 caracteres',
|
||||
'category_id.exists' => 'A categoria não existe',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user