Skip to content
Mark Broersen edited this page Aug 19, 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'
]
Clone this wiki locally