47 lines
1.5 KiB
PHP
47 lines
1.5 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Requests;
|
||
|
|
|
||
|
|
use Illuminate\Foundation\Http\FormRequest;
|
||
|
|
use Illuminate\Validation\Rule;
|
||
|
|
|
||
|
|
class UpdateCustomerRequest extends FormRequest
|
||
|
|
{
|
||
|
|
public function authorize(): bool
|
||
|
|
{
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function rules(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'type' => 'sometimes|in:private,business',
|
||
|
|
'company_name' => [
|
||
|
|
'sometimes',
|
||
|
|
'nullable',
|
||
|
|
'string',
|
||
|
|
'max:100',
|
||
|
|
],
|
||
|
|
'first_name' => 'sometimes|string|max:50',
|
||
|
|
'last_name' => 'sometimes|string|max:50',
|
||
|
|
'email' => [
|
||
|
|
'sometimes',
|
||
|
|
'email',
|
||
|
|
'max:100',
|
||
|
|
Rule::unique('customers')->ignore($this->customer),
|
||
|
|
],
|
||
|
|
'phone' => 'nullable|string|max:20',
|
||
|
|
'tax_number' => 'nullable|string|max:50',
|
||
|
|
'vat_id' => 'nullable|string|max:50',
|
||
|
|
'billing_address' => 'sometimes|array',
|
||
|
|
'billing_address.street' => 'required_with:billing_address|string|max:100',
|
||
|
|
'billing_address.city' => 'required_with:billing_address|string|max:50',
|
||
|
|
'billing_address.postal_code' => 'required_with:billing_address|string|max:10',
|
||
|
|
'billing_address.country' => 'required_with:billing_address|string|size:2',
|
||
|
|
'payment_terms' => 'nullable|integer|min:1',
|
||
|
|
'status' => 'nullable|in:active,inactive,prospect',
|
||
|
|
'notes' => 'nullable|string',
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|