I'm using Laravel with passport to auth in my API, but I have a questioning about what is the best way to User and Admin can edit user info?
The best way is something like that?
public function update(Request $request, $id)
{
$id = isset($request->user()->isAdmin) ? $id : $request->user()->id;
// Do something
}
And another problem is with the route
, because I have ( Example ):
Route::apiResource('users', 'UsersController')->middleware('auth:user, admin');
Note: My administrator doesn't have this property "isAdmin" is required? Or does Laravel get from the name defined in App/Config
?