Laravel Community Tools by Tighten

Recent tricks

458 tricks
When doing some sort of filtering in Eloquent, sometimes you need to use operators other than "=" and there is no easy way to know which operators you can use. This trick details the possible operators for you.
msurguy 12 years ago 23758
Did you know that Laravel comes with a great amount of helpers to generate HTML in your Blade templates, like UL and OL lists, obfuscating email links, links to javascript and style assets? Check out the code below to see the HTML helpers in action.
msurguy 12 years ago 37329
Put this in your routes.php file and you will see the SQL that Eloquent is executing when you go to pages that have any sort of access to Eloquent models. This helps a lot when debugging SQL in Laravel.
msurguy 12 years ago 125601
It can sometimes be convenient to automatically validate your model when it gets created or updated. This is very easily achieved with Laravel through the use of Model events.
stidges 12 years ago 16346
Laravel offers a dynamic interface for assigning certain data. This can be used e.g. for adding a dynamic 'where' to your Eloquent queries. However, not everyone know that this same trick also works on View assignments!
stidges 12 years ago 12647
I like namespacing my controllers. I think it cleans up my structure a bit, and prevents me from having to 'composer dump-autoload' everytime I make a new controller. Though it is very convenient to namespace your controllers, your routes file can quickly become very messy. Luckily, Laravel 4.1 offers a great solution for this, namely the 'namespace' option in Route::group().
stidges 12 years ago 73632
4.1
Usually you would use @section and @stop to pass data to a Blade section. When your data is limited to a short text like page title you could use the second argument of @section to pass that data.
msurguy 12 years ago 7903
Ever find yourself wanting to only find models that have a certain relationship matching certain conditions? Laravel 4.1 makes this really easy, and introduces great eager loading constraints!
stidges 12 years ago 17720