Laravel Community Tools by Tighten

Recent tricks

458 tricks
symply dont register unessecary route you dont have to use facade, $router instance is set by the function in route provider with config cached and files compiled i get app booted in ~30ms vs ~50 on my dev server
d3v2a 10 years ago 8873
5.0
The Authorization feature that was introduced in 5.1.11 is designed around the idea of associating models with policies, but sometimes you want to be able to define an encompassing policy to check for capabilities at a higher level, in which case checking against models might not make sense. This trick allows defining abilities in the gate based on the methods defined in a policy class.
Riari 10 years ago 14585
5.0
Let's say, that your user provide inputs which has arrays like multiple accounts and different crediting and debiting amount, and you need to validate if they are balancing. You will need to extract the array and do some sort of manipulations before proceeding to validation...You can just overload the all() method in your form request class
kamaroly 10 years ago 12734
5.0
Let's say that your validation is conditional on multiple rules.... This is a bit tricky because it's not obvious how to get the other rules passed to the validator. Here's how you'd do it
sgelbart 10 years ago 9042
4.0
I have some pages that I like to popup in an informative ajax modal as well as having their own page. However as those pages extend a layout within the template I was getting the whole page with layout in my modal. Using renderSections() was the solution. In the example below my template section was called 'content'
leoden 10 years ago 13274
When registering a model observer using `Model::observer(Observer::class)`, you can return false and laravel will cancel the method.
stevebauma... 10 years ago 21138
if you need to make a single ton class and you need to access that in your whole application do that in laravel 5
wasiqaftab 10 years ago 7605
sending variable values to your multiple controller and accessing them in your blade template
wasiqaftab 10 years ago 9598