Laravel Pro Tips
TIL, you use the File::json() method in Laravel 10 to retrieve a file and decode its contents automatically.
So simple — yet so elegant. ✨
So I heard y'all like types in your ORM.
Laravel allows you to define casts at the model level to handle casting values to their native types.
More interestingly, it also allows you to define them at query time, so you're not sacrificing the power of SQL 💅
Another day, another Laravel tip.
If you need to catch exceptions and don't want to stop the execution of further code, please make sure you use report(). Make it easy for yourself to log the problems!
#laravel #php #phpc
Laravel Tip 💡
When you want to share the same route based on user role, you can use a middleware to bind the suitable controller conditionally to an alias and then use it in the route closure. #Laravel
Mhamed Talhaouy 🪐
Finding out the total time taken by #HTTP Client Request in #Laravel
Laravel tip. If you want to get the list of the columns for a certain table, it's easy.
Povilas Korop | Laravel Courses Creator & Youtuber
🌟 Eloquent tip
If you need to insert or update a whole bunch of records in a loop, don't use `Model::updateOrCreate`.
Instead, use the `DB` facade's `upsert` method to use your database's built-in upsert functionality to do the whole thing in one query!
Kai Sassnowski 🥔
If you ever need to build a quick CSV export command for your Laravel application.
This is how I would recommend doing it. Open a resource to StdOut and then chunk your results and write them to the output using fputcsv(). It'll handle the CSV output perfectly 👌
Here's a pro tip 🔥 for all you Laravel developers: You can customize the default order of data retrieved from relationships!
#Laravel #PHP #PHPRC
Mohammad Haris ⚡