Laravel Pro Tips
#arrays #fluent
๐ถ๏ธ #Laravel Tip: Come and learn about ๐๐ก๐ช๐๐ฃ๐ฉ, a hidden gem in Laravel! You use a Fluent class to wrap over an Array. Fluent offers: โ Safe access to elements โ Array-Like or stdClass-Like access #PHP #Developers
Bilal Haidar
#cache
๐ฅ #Laravel Tip: Expensive queries (that return values which donโt change very often) are prime candidates for caching. Make use of the โrememberโ method for this purpose:
Matt Kingshott
#routes
In laravel, you may use the named method on a route instance to check if the current request was routed to a given named route #programming #100DaysOfCode #php
Faruk Nasir
#carbon #timezones
โ๏ธโฐ When working with Carbon/timezones, you should be aware that setting the timezone during construction is not the same as altering the timezone later. ๐
Freek Van der Herten ๐ญ
#migrations #eloquent #database
๐ฅ #Laravel #Eloquent Tip: The new concept "invisible column" in MySQL8 enables you to hide the column value when you run the `select *` query. To get the value you need to `select` explicitly. In Laravel use `->invisble()` in table migration. #Database #PHP
Laravel Eloquent
#collections
Just discovered that there is a method to check whether a Laravel collection contains exactly one item or not. I've written my last count() === 1 ๐
Daniel Eckermann
#eloquent #performance
๐ก#Laravel #Eloquent Advice: Instead of aggregate functions (count, max, min, avg, sum) on the collection, you can directly call them on the database itself. It is more efficient. #Laravel #Database #PHP
#eloquent #relationships
๐ถ๏ธ #Laravel Tip: Favor ๐๐๐จ๐๐๐ฃ๐ฎ over ๐๐๐ก๐ค๐ฃ๐๐จ๐๐ค side of the relationship when creating related records in the database. hasMany() side of the relationship makes your statements simpler and easier to read. ๐ #PHP #Developers
#commands #artisan
๐ถ๏ธ #Laravel Tip: Inside an ๐ผ๐ง๐ฉ๐๐จ๐๐ฃ ๐พ๐ค๐ข๐ข๐๐ฃ๐, you can execute bash scripts using the ๐๐ญ๐๐() function. Here's an example with an explanation ๐ #PHP #Developers