In this blog, i will show you how to get last executed query in Laravel 6. you can get last executed query using enableQueryLog() and getQueryLog() in laravel 6.
You can use DB::getQueryLog() function to get all executed queries.If you want to get the last executed query then use end().
Before getting query log you need to first enable it by using DB::enableQueryLog() function and then you can get all executed queries.
public function lastQuery()
$list = \DB::table("users")->get();
$query = \DB::getQueryLog();
"query" => "select * from `users`"
"bindings" => 
"time" => 6.96
If there are multiple Database connections then you must specify it by following way:
Now you can get log for that connection :
It will help you...