We have been many time require to get executed query log or you want to get last executed query or maybe if you want to display or Debug sql query from laravel Database query builder then you can do it that. when you are working on laravel application at that times , We think you require many time to print or debug last run query or if you want to check direct from phpmyadmin sql box, therefore at that time you have to step by step this four Debugging example.
In this Debugging example we can get directly get current sql query using toSql() of laravel Database query builder. In this Debugging example you don’t require to enable query log or something you can directly query like bellow example: Ok, In this Debugging example we must require to enable query log using DB::enableQueryLog() of Laravel 5/6/7 Database Query builder.
In this Debugging example We make the same as Debugging example 2, but you can get exactly last query using end().