When we are doing developement in laravel ,some times we want to see last executed query for debugging.DB::getQueryLog() function of laravel return all executed queries. To get last query we will use end() function which return last executed query.
$query = DB::getQueryLog(); $lastQuery = end($query);
Here is simple example,where we will get last executed in laravel.
$student = DB::table('student')->get(); $query = DB::getQueryLog(); $lastQuery = end($query); print_r($lastQuery);
Array ( [query] => select * from `student` [bindings] => Array ( ) [time] => 0.40 )