Skip to content

Instantly share code, notes, and snippets.

@lozadaOmr
Last active August 29, 2015 14:01
Show Gist options
  • Save lozadaOmr/1c197b26d2085c79ad2a to your computer and use it in GitHub Desktop.
Save lozadaOmr/1c197b26d2085c79ad2a to your computer and use it in GitHub Desktop.
Attach to User model - checks if Auth::user has role 'admin'
/**
*
* Checks whether the User has role of Admin
*
*/
public function isAdmin()
{
$isAdmin = false;
$isAdmin = !$this->roles->filter(function($item) {
return $item->role == 'admin';
})->isEmpty();
return $isAdmin;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment