Monday, 21 June 2021

Get Last Executed Query in Laravel

 Last Query in Laravel

DB::enableQueryLog();
$product = Product::get();
$query = DB::getQueryLog();
dd($query);
  1. \DB::enableQueryLog();
  2. $list = \DB::table("categories")->get();
  3. $query = \DB::getQueryLog();
  4. print_r(end($query));