40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class UpdateContractRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
$clientCase = $this->route('client_case');
|
|
$uuid = $this->route('uuid');
|
|
|
|
return [
|
|
'reference' => [
|
|
'nullable',
|
|
'string',
|
|
'max:125',
|
|
Rule::unique('contracts', 'reference')
|
|
->where(fn ($q) => $q
|
|
->where('client_case_id', optional($clientCase)->id)
|
|
->whereNull('deleted_at')
|
|
->where('uuid', '!=', $uuid)
|
|
),
|
|
],
|
|
'start_date' => ['sometimes', 'date'],
|
|
'type_id' => ['required', 'integer', 'exists:contract_types,id'],
|
|
'description' => ['nullable', 'string', 'max:255'],
|
|
'initial_amount' => ['nullable', 'numeric'],
|
|
'balance_amount' => ['nullable', 'numeric'],
|
|
];
|
|
}
|
|
}
|