Cara mencatat kueri di Laravel
DB::enableQueryLog();
$arr_user = DB::table('users')->select('name', 'email as user_email')->get();
dd(DB::getQueryLog());
Indian Gooner
DB::enableQueryLog();
$arr_user = DB::table('users')->select('name', 'email as user_email')->get();
dd(DB::getQueryLog());
DB::enableQueryLog();
$user = DB::table('users')->select('name', 'email as user_email')->get();
dd(DB::getQueryLog());
Method #1
instead of ->get use ->toSql() on query
$users = User::orderBy('name', 'asc')->toSql();
echo $users;
// Outputs the string:
'select * from `users` order by `name` asc'
Method # 2
DB::enableQueryLog();
// and then you can get query log
dd(DB::getQueryLog());