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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners