Our first step should be

DB::connection()->enableQueryLog();

After our query, it should be placed

$querieslog = DB::getQueryLog();

After that, it should be placed

dd($querieslog)

BY Best Interview Question ON 17 Sep 2022

Example

DB::connection()->enableQueryLog();
$result = Blog:where(['status' => 1])->get();
$log = DB::getQueryLog();
dd($log);

Suggest An Answer