Skip to content

Instantly share code, notes, and snippets.

@Kindari
Created March 18, 2013 15:59
Show Gist options
  • Select an option

  • Save Kindari/5188241 to your computer and use it in GitHub Desktop.

Select an option

Save Kindari/5188241 to your computer and use it in GitHub Desktop.
Role based router filtering for Laravel 3
<?php
Route::get('protected', array('before' => 'auth|has_role:admin', function(){
return "sekrit";
}));
Route::filter('has_role', function($role) {
if ( ! Auth::user()->has_role($role) ) {
return 'unauthorized';
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment