Created
October 12, 2012 15:19
-
-
Save Kindari/3879716 to your computer and use it in GitHub Desktop.
Laravel Filter Route based on Role
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Route::get('protected', array('before' => 'auth|role:admin', function() { | |
return "Only admins can see this"; | |
})); | |
Route::filter('role', function ($role) { | |
if ( ! Auth::user()->has_role( $role ) ) | |
{ | |
return Response::error("401"); // not authorized | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment