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