mwal mwal - 26 days ago 5x
PHP Question

Laravel View::composer()

What is the right circumstance to use these?

If I have a view partial which always needs the same data (say to fill out some nav links) and I provide that data in a view composer, do I need to worry about cases where the main page also needs, and loads, this data?

i.e. is it possible to end up calling for the same data twice?


short answer is yes, you might call for the same data twice.

try adding


before any database calls, and in the end, before the view is returned, do this:


Then you can see if you are calling the same data twice, in the query log.