Laravel Community Tools by Tighten

Recent tricks

458 tricks
This trick is handy for wrapping all of your form elements with the same HTML/classes, which is especially useful for handling error states when using frameworks like Bootstrap or Foundation.
crhayes 12 years ago 12328
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 12126
I have put together a custom collection that will allow you to access a relationship on all objects in a collection. You can also run a method from an object in the collection on the entire collection such has touch or delete.
riddles888... 12 years ago 32207
4.0
If you're not making use of MySQL InnoDB cascades, you might still want to cause events (such as deleting) on related models to cascade. The example below listens for the deleted event on the Product model and cascades this to the child models.
robjmills 12 years ago 34842
When you need to pass more attributes to a form element using blade syntax.
ramirors 12 years ago 24849
This is specific to using Redis for caching. You can group your keys in sections to allow for easily clearing the cache on just a section of data. Couple notes: 1. You have to have 'cluster' set to false in app/config/database.php under the 'redis' key. 2. Remember to pass through variables into the closure with 'use'. 3. Have fun!
gerob 12 years ago 14191
Use laravel pagination with this small bit of jquery to ajax load paginated results. Create a page with the data you wish to paginate. http://www.example.com/paginated/data
riddles888... 12 years ago 44698
Perform CSRF filter on all post, put, patch, and delete requests through constructor of the BaseController.
mhanson01 12 years ago 18243
This snippet can be used to view a linked list to all your available views, useful for reviewing different screens.
mohamed 12 years ago 11071