I am beginner in Laravel. I use in my project Laravel 6.
I have this code (UserRequest):
return $this->isIndividualClient()
? [
'info.first_name' => ['required', 'max:191', 'alpha_dash'],
'info.last_name' => ['required', 'max:191', 'alpha_dash'],
'info.birth_place' => ['required', 'max:191'],
'info.birth_date' => ['required'],
'email' => ['required', 'email', Rule::unique('clients')->ignore($this->route("client"))->whereNull('deleted_at')],
'info.phone_nr' => ['required', 'max:191'],
'info.address' => ['required', 'max:191'],
'info.city' => ['required', 'max:191'],
'info.postal_code' => ['required', 'max:191']
]
: [
'company_info.name' => ['required', 'max:191'],
'email' => ['required', 'email', Rule::unique('clients')->ignore($this->route("client"))->whereNull('deleted_at')],
'company_info.nip' => ['required', new Nip],
'company_info.phone_nr' => ['required', 'max:191'],
'company_info.address' => ['required', 'max:191'],
'company_info.city' => ['required', 'max:191'],
'company_info.postal_code' => ['required', 'max:191'],
'address.company_name' => ['required', 'max:191'],
'address.nip' => ['required', new Nip],
'address.address' => ['required', 'max:191'],
'address.city' => ['required', 'max:191'],
'address.postal_code' => ['required', 'max:191'],
];
I need add if statement in my validation:
if($request->input('need_invoice'){
'address.company_name' => ['required', 'max:191'],
'address.nip' => ['required', new Nip],
'address.address' => ['required', 'max:191'],
'address.city' => ['required', 'max:191'],
'address.postal_code' => ['required', 'max:191'],
}
If user / post individual user and need't invoice - this part of validation I need turn off.
How can I make it?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire