I'm looking for suggestions and a point to reference how to show/validate client signature fields. I have a web development/digital advertising contract form with a payment / approval section that contains a few text boxes and a signature pad. I need to require and display these fields if a client is logged in. not required/displayed if an admin or sales staff is logged in.
I was looking at the "required_if", "required_unless", etc. validation clause(?). I currently have Laravel Breeze installed. Will this work or would I need something more to handle roles (and permissions).
At the moment, I only have basic rules set up which looks like this.
If you create a form request, you can check if the user is authenticated, and which type of a user, and based on that return appropriate rules from the rules method.
public function rules(): array
{
$rules = [
'name' => 'required|boolean',
];
if ($this->user()) { // this is to check if they are logged in
$rules['something'] = 'required|string';
}
if ($this->user()->isSomething()) { // here you check for a type
$rules['something-else'] = 'required|string';
}
return $rules;
}