user() !== null; } /** * Get the validation rules that apply to the request. * * @return array|string> */ public function rules(): array { $rules = [ 'type' => ['required', new EnumValue(MessageType::class)], 'body' => ['required', 'string', 'max:65535'], 'files' => ['nullable', 'array'], 'files.*' => ['file', 'max:10240'], // 10MB per file ]; $type = $this->input('type'); if (in_array($type, ['situation', 'confirmation'])) { $rules['files'] = ['required', 'array', 'min:1']; } return $rules; } /** * Get custom attributes for validator errors. * * @return array */ public function attributes(): array { return [ 'body' => 'message', 'files' => 'fichiers', ]; } }