Neustrukturierung Customer / Lead / Booking Phase 2
This commit is contained in:
parent
313f0dbf4e
commit
6df9c401af
69 changed files with 3809 additions and 374 deletions
60
app/Http/Requests/Offer/StoreOfferRequest.php
Normal file
60
app/Http/Requests/Offer/StoreOfferRequest.php
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Offer;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
class StoreOfferRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->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.',
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue