mwal mwal - 1 month ago 6x
PHP Question

View partials - duplicating queries?

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

i.e. is it possible to end up calling for the same data twice?
(a potential gotcha in using view composers?) does this matter? Am I "pushing the framework?"


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.