Laravel print query or dubug query

To get the sql query, we can use enableQueryLog static method to print query.

We can use:

 DB::enableQueryLog(); // Enable query log
 // Your Eloquent query
dd(DB::getQueryLog()); // Show results of log


We can use toSql() to print the sql query.



select * from products

That’s it!. Please share your thoughts or suggestions in the comments below.

Leave a Reply

Your email address will not be published. Required fields are marked *