๐ง๐ถ๐ฝ ๐ผ๐ณ ๐ง๐ต๐ฒ ๐๐ฎ๐ ๐ณ๐ผ๐ฟ ๐๐ฎ๐ฟ๐ฎ๐๐ฒ๐น๐ถ๐ฎ๐ป๐โค๏ธ
Hey! Guess what?
๐ง๐ต๐ฒ๐ฟ๐ฒ'๐ ๐ป๐ผ ๐ป๐ฒ๐ฒ๐ฑ ๐๐ผ ๐๐๐ฒ "๐ณ๐ผ๐ฟ๐ฒ๐ฎ๐ฐ๐ต()" ๐น๐ผ๐ผ๐ฝ๐ ๐ถ๐ป ๐๐ผ๐๐ฟ ๐๐ฎ๐ฟ๐ฎ๐๐ฒ๐น ๐๐ฝ๐ฝ๐ anymore because Laravel has its own built-in ๐๐ผ๐น๐น๐ฒ๐ฐ๐๐ถ๐ผ๐ป ๐๐ฒ๐น๐ฝ๐ฒ๐ฟ๐ to make your life easier!
๐๐ฌ๐ ๐๐๐ฌ๐
Imagine youโre building an e-commerce app where customers place orders. Each order has multiple items (order_items), and each item is linked to a product. Each product has a weight or volume attribute & you have to fetch the sum of weight or volume of all products for calculating your delivery charges.
๐ช๐ถ๐๐ต๐ผ๐๐ ๐๐ผ๐น๐น๐ฒ๐ฐ๐๐ถ๐ผ๐ป ๐๐ฒ๐น๐ฝ๐ฒ๐ฟ๐: Youโd have to write a loop maybe nested loops to calculate the total weight or volume of all products in the order.
๐ช๐ถ๐๐ต ๐๐ผ๐น๐น๐ฒ๐ฐ๐๐ถ๐ผ๐ป ๐๐ฒ๐น๐ฝ๐ฒ๐ฟ๐: You can use Laravelโs pluck() and sum() methods to do the same thing in just one
Back