DEV Community

Discussion on: Only allow owners to update their user profile in Laravel with a policy

Collapse
 
martin_betz profile image
Martin Betz

Thanks to Reddit user reddit.com/user/Re-Infected/, here's an simpler update() method:

public function update(User $user, User $user_model)
{
  return $user->is($user_model) ?: Response::deny();
}

In plain English: If the logged in user is equal to the user passed then return true (= pass this request), if not deny the update process.