Laravel Community Tools by Tighten

Tag "4.0" tricks

68 tricks
I have added a sitemap to this very site and was thinking that some of you want to do the same for SEO purposes. The way to add a sitemap would be pretty easy by using a Blade template for the XML that sitemap requires but there is an easier solution. You can use a package from https://github.com/RoumenDamianoff/laravel4-sitemap that would make it super simple to generate a sitemap for your Laravel application. See for yourself.
msurguy 12 years ago 35202
I spent a good hour trying to figure out why my Eloquent relationship wasn't working when I found out it was because of the difference between `$model->relationship->value` and `$model->relationship()->value`.
chadwithuh... 12 years ago 109815
This is a laravel command i wrote to handle the upgrade to 4.1 It covers everything in the upgrade doc except for handling missing method. It should be easily addable if you need it. Make sure to add the following to start/artisan.php Artisan::add(new UpgradeCommand); Artisan::resolve('UpgradeCommand'); Once finished, run the following php artisan auth:reminders-controller
stygian 12 years ago 11517
4.0
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 51163
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 12424
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 12137
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 32231
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 34866
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 14205