|string> */ public function rules(): array { $file = match ($this->input('collection', 'gallery')) { 'voice_note' => ['required', 'file', 'mimetypes:'.self::AUDIO_MIMETYPES, 'max:20480'], 'gallery' => [ 'required', 'file', 'mimetypes:image/jpeg,image/png,image/webp,'.self::VIDEO_MIMETYPES, 'max:102400', ], default => ['required', 'image', 'mimes:'.self::IMAGE_MIMES, 'max:10240'], }; return [ 'file' => $file, 'collection' => ['nullable', 'in:key_image,gallery,voice_note'], // Sent along with the file when the note was written before the // upload could happen (offline), so it needs no second request. 'caption' => ['nullable', 'string', 'max:500'], ]; } /** * @return array */ public function messages(): array { return [ 'file.mimetypes' => 'Dieses Dateiformat wird hier nicht unterstützt.', 'file.mimes' => 'Dieses Dateiformat wird hier nicht unterstützt.', 'file.image' => 'Für das Key Image ist nur ein Bild erlaubt.', 'file.max' => 'Die Datei ist zu groß.', ]; } }