Teren-app/app/Http/Requests/UpdateContractRequest.php
2025-09-28 22:36:47 +02:00

41 lines
1.2 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'],
'account_type_id' => ['sometimes', 'nullable', 'integer', 'exists:account_types,id'],
];
}
}