Skip to content

Instantly share code, notes, and snippets.

@Mombuyish
Created April 14, 2018 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mombuyish/0042a3918ffe4772ec2c6e5754a09e63 to your computer and use it in GitHub Desktop.
Save Mombuyish/0042a3918ffe4772ec2c6e5754a09e63 to your computer and use it in GitHub Desktop.
<?php
abort_if(! Auth::user()->isAdmin(), 403);
abort_if(! Auth::user()->isAdmin(), 403, 'Sorry, you are not an admin');
abort_if(Auth::user()->isCustomer(), 403);
// In "admin" specific controller
public function index()
{
if (! Auth::user()->isAdmin()) {
abort(403, 'Sorry, you are not an admin');
}
}
// better!
public function index()
{
abort_if(! Auth::user()->isAdmin(), 403);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment