Skip to main content

Command Palette

Search for a command to run...

Laravel Debugging: Essential Functions for Developers

Published
1 min read
Laravel Debugging: Essential Functions for Developers
M

I am Mandeep Singh, a full-stack developer. I created this Blog to bestow my coding experience and love to write on JavaScript, Next.js, Laravel and little bit Unity Game development.

Raw Query Output With Bindings is Coming to Laravel 10

User::where(...)->ddRawSql();
// Using the new `toRawSql()` method
User::where('email', 'mandeep@example.com')->toRawSql();
// "SELECT * FROM users WHERE email = 'mandeep@example.com'"

There is some prior art before toRawSql()—various developer tools (i.e., Laravel Debugbar) give you queries, and there's a dd() method you can use as well:

// Using the dd() method
User::where('email', 'mandeep@example.com')->dd();
// "SELECT * FROM users WHERE email = ?"
// [
//  0 => "mandeep@example.com"
// ]

More from this blog

Mandeep Singh Blog

117 posts