Laravel Pro Tips
#encryption
Laravel Tip: If we want to put "sensitive" data in our DB then we can use Crypt Facade and handle these using accessors and mutators. #Laravel #PHP
Theodoros Kafantaris
#requests #middleware
Laravel Tip π‘ Did you know you can enrich request data using a middleware? For example, resolve the user origin country using their IP and add the country abbreviation to the request.
Philo Hermans
#eloquent #relationships
An efficient way of checking if a relation exists in Laravel is to use withExists. It performs a simple existence check and returns a boolean. By default it would return a "posts_exists" value on the User. You may alias it like in the example below to make it more readable.
Daniel Eckermann
#cheatsheet #DB
πA #Laravel DB Cheatsheet Part 1/5 π₯π₯ #PHP πPart 2 coming tomorrow π
Aaron Lumsden π | Indie Hacker Dev
#eloquent #collections #null
π‘ #Laravel Tips of the day π ππΌπ»βπ ππΆπΉππ²πΏ π―π π‘π¨ππ πΆπ» ππΌπΉπΉπ²π°ππΆπΌπ»π: We can filter by NULL in Eloquent, but if we're filtering the collection further - filter by empty string, there's no "null" in that field anymore. #php #backend
vigowebs
#eloquent #sorting
π₯ #Laravel Tip: Make use of βorderByRawβ when you need to sort records in a more complex manner than simply A-Z or Z-A. Hereβs an example where I sort βrolesβ based on their level of importance (rather than their alphabetical order).
Matt Kingshott
#eloquent #database #aggregates
π₯ #Laravel Tip: Hereβs a simple, but important oneβ¦ particularly if youβre new to the framework. Make sure that aggregations are done within the DB and not Laravel. Go even further with indexes and WHERE constraints:
#gates #cheatsheet
π A #Laravel Gate #cheatsheet #PHP π₯β‘οΈ
#files #cheatsheet
π #Laravel File #cheatsheet #php π₯π₯ β‘οΈAre there any of these methods that you weren't aware of?