| Current Path : /var/www/html/LLCF-APP/app/Http/Requests/ |
| Current File : /var/www/html/LLCF-APP/app/Http/Requests/UpdateFamilyRequest.php |
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UpdateFamilyRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'father_name' => 'required|string|min:3',
'father_cnic' => [
'required',
'regex:/^\d{5}-\d{7}-\d{1}$/',
'max:15',
'unique:family,father_cnic,' . $this->route('id')
],
'father_phone' => ['required', 'regex:/^03\d{9}$/'],
'father_occup' => 'required|string',
'address' => 'required|string',
'mother_name' => 'required|string',
'mother_cnic' => ['required', 'regex:/^\d{5}-\d{7}-\d{1}$/'],
'mother_occup' => 'required|string',
'children_count' => 'required|integer|min:0',
'zakat' => 'required|in:yes,no',
'religion' => 'required|string|max:12',
'emerg_name' => 'required|string',
'emerg_relation' => 'required|string',
'emerg_num' => ['required', 'regex:/^03\d{9}$/'],
];
}
public function messages(): array
{
return [
'father_cnic.regex' => 'Father CNIC must be in the format 12345-1234567-1',
'father_cnic.unique' => 'This CNIC is already associated with another family.',
'mother_cnic.regex' => 'Mother CNIC must be in the format 12345-1234567-1',
'father_phone.regex' => 'Father phone must be a valid 11-digit number starting with 03',
'emerg_num.regex' => 'Emergency number must be a valid 11-digit number starting with 03',
];
}
}