Laravel Community Tools by Tighten

Category "Routing" tricks

91 tricks
An easy helper method that will assist in setting active classes for navigation items based on the current route.
mattems 12 years ago 27621
If you have an API, which you also use on your site..then you might want to get the data from the API by making an internal request.
xtrasmal 12 years ago 19027
Check if the request matches the url. If so, add an active class to the menu item.
xtrasmal 12 years ago 12473
When you're into making an API, you may wish to make the format of the responses you provide dynamic. If you're not using controllers, you would make a class, but if you use controllers, it's a pretty good idea to place it in the base controller. As well you may restructure your response data to include more fields, e.g. for testing purposes you may wish to also include some custom debug.
vlakarados 12 years ago 13828
A Link assets based on which controller is currently requested. Any improvements to this code are welcome
JonathanFr... 12 years ago 11696
If you're like me, you don't like to keep repetitive ->where()'s in your routes file, this is where route patterns come in handy. Makes your routes file DRY too, especially when you'll need to change some expression.
vlakarados 12 years ago 51144
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 12413
Sometimes you would like to restrict a certain route parameter. For instance, if you are using route parameters to determine the ID of a certain model you are using, you would only like digits to be passed, not alphabetical characters. You can set these restrictions on the route using ->where('<pattern>'). But what if you have a huge list of routes that all use the same pattern restriction? That's where this will come in handy.
stidges 12 years ago 12129
Perform CSRF filter on all post, put, patch, and delete requests through constructor of the BaseController.
mhanson01 12 years ago 18247