db enable query log laravel code example
Example 1: How to Log Query in Laravel
DB::enableQueryLog();
$arr_user = DB::table('users')->select('name', 'email as user_email')->get();
dd(DB::getQueryLog());
Example 2: enablequerylog laravel
\DB::enableQueryLog();
dd(\DB::getQueryLog());
Example 3: How to Log Query in Laravel
DB::enableQueryLog();
$user = DB::table('users')->select('name', 'email as user_email')->get();
dd(DB::getQueryLog());
Example 4: laravel db query log string replacements
DB::enableQueryLog();
User::all();
$query = collect(DB::getQueryLog())->map(function($query){
return str_replace_array('?', $query['bindings'], $query['query']);
})->join("\n");
dd($query);
Example 5: db enable query log
DB::enableQueryLog();
dd(DB::getQueryLog());