Laravel Pro Tips
#collections
๐๐ป Laravel tip of the day You can use the "higher order messages" to refactor the logic that returns custom fields to a separate model method and feed it to the other collection method. For instance, the `map` method. This makes things tidier while building queries! #Laravel
Amit Merchant
#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 - Available 4 Laravel gigs
#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
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