Tuesday, March 21, 2017

Laravel helpers multiple calls different blade parts - Best Practices

I create a helper to get the count of unread messages, and i'm calling that function on on a couple of blades - Menu - Profile Menu

That helper made a db query to get that value, currently when I'm outside the profile, we get only one query, but when I'm on the profile section, since we call 2 time that function I have 2 query's, one for each call, AND when i'm on the message list, we call 3 times!

What is the best way to proceed on this kind of situation? I try to search on internet some kind of best practices but I couldn't found anything.

Thanks in advance. Pablo



via Pablo Ignacio de la Vega

Advertisement