Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cola's avatar
Level 1

Is it possible to see raw sql query?

Bill::with(['user', 'project'])->get();

Is it possible to see raw sql query of this?

0 likes
3 replies
chaudigv's avatar
use Illuminate\Support\Facades\DB;

DB::enableQuery();
Bill::with(['user', 'project'])->get();
dd(DB::getQueryLog()); // list of all the queries

Tray2's avatar

Or just do

Bill::with(['user', 'project'])->toSQL();

or

Bill::with(['user', 'project'])->dd();

or

Bill::with(['user', 'project'])->dump();

But I agree with @michaloravec that the debugbar is the best option if you don't have the Tinkerwell app.

Please or to participate in this conversation.