When we are working on any projects then many times we need to get last executed query, If you are working on laravel framework and use laravel query builder And want to get last executed mysql query from laravel. Then you have to first enable query log that way it can be store query log. At last getQueryLog() through you can get last executed query. I give you example of how to get last executed mysql query. you can use example as following example.
public function querylog()
$item = Item::find(2);
$last_query = DB::getQueryLog();