Photo by https://unsplash.com/@invent on https://unsplash.com Lisez ce billet sur https://rachids.ca/blog/les-pieges-dans-laravel-les-requetes-gourmandes :) When I started using Laravel, I really enjoyed the fact that I could simply grab all my data with a simple line of code: $products = Product::get(); Enter fullscreen mode

And the code above is loading everything: name, price, description, maybe a picture and so on.

For instance, if my view only needs name and price : // ๐Ÿ‘Ž I am loading every columns $products = Product::get(); // ๐Ÿ‘ I only load the specific columns I need $products = Product::select(โ€˜nameโ€™, โ€˜priceโ€™)->get(); Enter fullscreen mode
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners