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