*/ public function rules(): array { return [ 'photo' => [ 'required', 'image', 'mimes:jpeg,png,webp', 'max:10240', // 10MB ], 'caption' => ['nullable', 'string', 'max:500'], 'alt_text' => ['nullable', 'string', 'max:255'], 'tags' => ['nullable', 'array', 'max:10'], 'tags.*' => ['string', 'max:50'], ]; } /** * Get custom validation messages. */ public function messages(): array { return [ 'photo.required' => 'Ein Foto muss hochgeladen werden.', 'photo.image' => 'Die Datei muss ein Bild sein.', 'photo.mimes' => 'Nur JPEG, PNG und WebP Formate sind erlaubt.', 'photo.max' => 'Das Foto darf maximal 10MB groß sein.', 'caption.max' => 'Die Bildunterschrift darf maximal 500 Zeichen haben.', ]; } /** * Prepare the data for validation. */ protected function prepareForValidation() { $this->merge([ 'tags' => $this->tags ? explode(',', $this->tags) : [], ]); } }