Created
November 17, 2014 02:16
-
-
Save Glutnix/76ce2c4e7cdd2eb17dd2 to your computer and use it in GitHub Desktop.
Laravel 4.2 Route filters for checking ownership
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
Route::filter('admin', function() | |
{ | |
if (Auth::user()->role !== 'admin') return Redirect::to('login'); | |
}); | |
Route::filter('albumOwner', function($route, $request) | |
{ | |
$album = Album::findOrFail($route->getParameter('albums')); | |
if ( $album->user_id !== Auth::id() && Auth::user()->role !== "admin") { | |
return Redirect::to('login'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks to @kategriffiths for letting me figure this out for her project