53 lines
1.4 KiB
PHP
53 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin;
|
|
|
|
use App\Models\HouseholdMember;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class StoreAdminHouseholdMemberRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'relationship' => [
|
|
'required',
|
|
'string',
|
|
Rule::in([
|
|
HouseholdMember::RELATIONSHIP_HEAD,
|
|
HouseholdMember::RELATIONSHIP_SPOUSE,
|
|
HouseholdMember::RELATIONSHIP_CHILD,
|
|
HouseholdMember::RELATIONSHIP_PARENT,
|
|
HouseholdMember::RELATIONSHIP_SIBLING,
|
|
HouseholdMember::RELATIONSHIP_OTHER,
|
|
]),
|
|
],
|
|
'user_id' => [
|
|
'nullable',
|
|
'integer',
|
|
Rule::exists('users', 'id')->where(function ($query) {
|
|
$query->where('role', User::ROLE_RESIDENT);
|
|
}),
|
|
],
|
|
'full_name' => [
|
|
'required_without:user_id',
|
|
'nullable',
|
|
'string',
|
|
'max:191',
|
|
],
|
|
'date_of_birth' => [
|
|
'nullable',
|
|
'date',
|
|
'before_or_equal:today',
|
|
],
|
|
];
|
|
}
|
|
}
|