Laravel Community Tools by Tighten

Tag "5.0" tricks

75 tricks
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 14573
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 12727
5.0
When registering a model observer using `Model::observer(Observer::class)`, you can return false and laravel will cancel the method.
stevebauma... 10 years ago 21113
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 7596
sending variable values to your multiple controller and accessing them in your blade template
wasiqaftab 10 years ago 9591
The easy way to define Eloquent Global Scopes with https://github.com/jarektkaczyk/laravel-global-scope
jarektkacz... 10 years ago 8095
Get the base URL of your Laravel 5 app page available anywhere in your JavaScript for jQuery to use. To do this you could have the following code in your template.blade.php file...
cpaddison 10 years ago 32338
5.0
Session time out for logged in user (middleware way) for prevent dashboard or ... access after specify time. if we use this middleware in route groups, it will be run on every request under route group. with this code we do not need to change php.ini file or laravel session config file and default settings are appropriate. Do not forget to register middleware in app\Http\Kernel : 'timeout' => 'App\Http\Middleware\SessionTimeout', Other notices: 1- we can use middleware paramaters in laravel 5.1 for custom conditions. 2- we must redirect user back (after session timeout and log out ), to prevent user navigate to come back. 3- we must show a message to user (after session timeout and log out), that you logged out after [20] minutes that you were not active. Our Persian web app for time management is: https://timenix.com If you have a better idea please comment it. ♥
ivahidmont... 10 years ago 87593