Check number of queries run

Check how many queries Laravel runs.

Sometimes you mat want to see how many queries Laravel has just run.

It may come handy, when using ‘eager loaded’ relations.

Just to make sure, if you are really ‘eager loading’ stuff.

Also, it is handy to see query as it was passed to SQL server in raw SQL code.

Of course, we have helper function toSql(), but in some cases this method is better:

And this is a result you will get on the screen:

Above example shows, that we have run 2 queries.

Of course you can accomplish this in many different ways, including systemic.
But I prefer surgical placement of testing tool, where I need it.

You can also read more here: