I'm using Laravel as an API with Passport Password Grant Token. I need to validate user attributes from the request but I'm getting an error with validate()
method.
My update
method below...
public function update(Request $request)
{
$attributes = [
'last_name' => ['string'],
'first_name' => ['string']
];
$validator = $request->user->validate($attributes);
if ($validator->fails()) {
return $validator;
}
}
...is returning this error log:
local.ERROR: Call to a member function validate() on array {"userId":1234,"exception":"[object] (Error(code: 0): Call to a member function validate() on array at /Users/me/my-project/app/Http/Controllers/UserController.php:122)
What's wrong in my code ?
$request->user->validate($attributes)
returns the error – DevonDahon