mwal mwal - 2 months ago 16
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?"

Answer

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

try adding

DB::enableQueryLog();

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

var_dump(DB::getQueryLog());

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

Comments