|string> */ protected function prepareForValidation(): void { if ($this->has('order')) { $this->merge([ 'order' => (int) $this->order ]); } } 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 'order' => 'nullable|integer|min:0', ]; } 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', 'order.integer' => 'O ordem deve ser um número inteiro', 'order.min' => 'A ordem deve ser maior ou igual a 0', ]; } }