Laravel has always been amazing to me on how much we can make stuffs for ourselves. Not just coding, but implementing functions that are useful to application too.
Macro is the one the best feature, developer adore in this framework.
Imagine you retrieve data from eloquent model like Model::all(). Here, You did not retrieve a single instance, you retrieved collection.
So, now you need to do something with it.
Let’s say you are looping over and printing values over tr and td combination in a table.
You will hate it when you have to do this every time.
So, to use macro here would be useful.
Better yet those “id” and “name” can also be passed as function arguments. But, we can do optimization as we like.
Everything is awesome.