When working with Laravel, you will probably use the query builder in order to create and run database queries. Sometimes you want to see the raw SQL output of a query, for example when you are debugging.
The easiest way to get the raw SQL output of this query, is by using the toSql() method: This will result in: It is fast and simple, but as you can see, the bind parameter for amount > 400 is shown as amount > ?.
You can also capture queries by listening for database events in the boot() method of your AppServiceProvider: This will return the query, and the bindings.
If you don't want to get the raw SQL output of a query programmatically, there are quite some tools out there that can do this for you.