I have used front end is Angular and backend is Laravel, Create user call store function, it triggers to validate the user request using "UserRequest".
All validation working perfectly.
Now I will update the user record based on the field value change, not all fields.
The UserController update function triggers while updates the record, but not all fields I passed to update. one specific field.
Example:
The requests pass "Age=40" to the only update. but UserRequest validates all the fields and throw the error required fields. How to I use reuse the request also achieve the output.
// UserController
public function store(UserRequest $request)
{
//TODO...
}
and
// UserRequest
public function rules()
{
return [
'name' => 'required',
'email' => 'required|email',
'age' => 'required|integer|min:15',
];
}
and
// UserController
public function Update(UserRequest $request, User $user)
{
//TODO...
$user->update($request->all());
}