Back

image
๐—ง๐—ถ๐—ฝ ๐—ผ๐—ณ ๐—ง๐—ต๐—ฒ ๐——๐—ฎ๐˜† ๐—ณ๐—ผ๐—ฟ ๐—Ÿ๐—ฎ๐—ฟ๐—ฎ๐˜ƒ๐—ฒ๐—น๐—ถ๐—ฎ๐—ป๐˜€โค๏ธ

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

โ€ข โ€ข

25

โ€ข

0 / 1000