Skip to content
Mark Broersen edited this page Aug 20, 2021 · 3 revisions

Show queries inline

Dump and die

User::join('posts', 'posts.users_id', '=', 'users.id')
->select([DB::raw('SUM(posts.id)')])
->where('users.id', 1)
->select([DB::raw('SUM(post.id)')])->qadd();

or just dump

User::join('posts', 'posts.users_id', '=', 'users.id')
->select([DB::raw('SUM(posts.id)')])
->where('users.id', 1)
->select([DB::raw('SUM(post.id)')])->qadump();

both dump this array

[
   'toSql' => 'select sum(posts.id) from users join posts on posts.users_id = users.id where users.id = ?'
   'bindings' => [1]
   'query' => 'select sum(posts.id) from users join posts on posts.users_id = users.id where users.id = 1'
]

Start query logging session

  1. To start a query log session goto {app_url}/query-adviser/
  2. Press play and open the pages of your app you want to log the queries of
  3. Stop the session and click on the session bar to see all the details.

Session stepper

Query Overview

Clone this wiki locally