Laravel Community Tools by Tighten

Tag "filters" tricks

34 tricks
Route::filter() passes multiple filter params as individual values like function($route, $response, $param1, $param2 ...) this is an easy way to check against multiple params. If I'm checking permissions like this ->before('permission:user,moderator') this makes it easy to check against. Since Route::filter() passes $route and $response in a BEFORE filter the array_slice strips them out of the array to allow you to check against the values you want.
bgallagh3r 12 years ago 8563
Catch all routes and paths using the auth filter. A route validation method is added to the Users model called hasAccess($route) and returns true if the user has that route. If the user doesn't have the route the error message will inform of what access they are missing.
somadden 12 years ago 9973
Perform pattern based CSRF filter on all post, put, patch, and delete requests. Just add this code snippet at the top of routes.php
Illusion 12 years ago 6657
A Controller-based solution to add the CSRF filter to all POST requests.
danalloway 12 years ago 9002
Laravel 4 CSRF on all POST requests
localdisk 12 years ago 10178
An example of how I did my filters.php and routes.php to populate many of the same structured routes. Used Sentry 2 for Authentication and short syntax for array() Suggestions to make it even DRYer are welcome. php artisan route output of the example http://paste.laravel.com/1cnE
XoneFobic 12 years ago 12560
Perform CSRF filter on all post, put, patch, and delete requests through constructor of the BaseController.
mhanson01 12 years ago 18445