user() !== null; } public function rules(): array { return [ 'contact_id' => [ 'nullable', 'integer', Rule::exists('contacts', 'id'), ], 'inquiry_id' => [ 'nullable', 'integer', Rule::exists('inquiries', 'id'), ], 'template_id' => [ 'nullable', 'integer', Rule::exists('offer_templates', 'id')->whereNull('deleted_at'), ], 'booking_id' => [ 'nullable', 'integer', Rule::exists('booking', 'id'), ], ]; } public function withValidator(Validator $validator): void { $validator->after(function (Validator $v) { if (! $v->fails() && $this->input('contact_id') === null && $this->input('inquiry_id') === null) { $v->errors()->add('contact_id', 'Bitte wähle einen Kontakt oder eine Anfrage.'); } }); } public function messages(): array { return [ 'contact_id.exists' => 'Der gewählte Kontakt existiert nicht.', 'inquiry_id.exists' => 'Die gewählte Anfrage existiert nicht.', 'template_id.exists' => 'Die gewählte Vorlage existiert (nicht) oder ist gelöscht.', 'booking_id.exists' => 'Die gewählte Buchung existiert nicht.', ]; } }