Laravel Pro Tips
#joins #eloquent
🔥 #Laravel Tip: Eloquent's 'whereExists' method is useful, but it relies on sub queries. A more efficient way to run the same query is an advanced inner join.
Matt Kingshott
#commands #artisan
🔥 Laravel Tip: Auto-completion in artisan commands. When you prompt a user for input, you can use the `anticipate` method to auto-complete possible responses.
Cosme Escobedo
#seeders #batches
🔥 #Laravel Tip: Seeding your database one record at a time can slow the DB to a halt. A better option is to use PHP to make a bunch of records and then seed them in chunks. Here’s how you can go from 10,000 queries to 5!
#eloquent #indexes
🔥 #Laravel Tip: Eloquent’s ‘whereDate’ function is useful, but it prevents the database from using an index, which can effect performance on large tables. Fortunately, it is easy to replace it with ‘whereBetween’:
#eloquent #refactor
🔥 #Laravel Tip: Eloquent provides a ‘withCount’ method, but it uses a sub-query, which can be up to 8 times slower (or more in some cases) than using a leftJoin & groupBy. Refactoring only requires a few changes and can make a big difference…
#routes #models
Laravel tip 💡You can use the 'resolveRouteBinding' method on your model to modify the value that is used to resolve the binding.
Philo Hermans
#requests #dates #timezones
😍 You can retrieve date from request in specific format and timezone 🤯 #laravel #laraveltips #laraveltricks #laravelforever
Laravel Updates | Tips and Tricks
#eloquent #relationships
🔥 #Laravel Tip: Eloquent offers many undocumented methods that can help to make your code easier to read. For example, the whereBelongsTo method simplifies finding resources that belong to a model instance.
#migrations
#Laravel Migration Tip 🔥 You can use the `from` method to set the starting value of an auto-incrementing field.
Gurmandeep Singh