print query in laravel code example
Example 1: print query statement in laravel
DB::enableQueryLog();
$users = User::select("*")->get();
$quries = DB::getQueryLog();
dd($quries);
DB::table('users')->toSql();
dd($query);
Example 2: print last sql query laravel
DB::enableQueryLog();
dd(DB::getQueryLog());
Example 3: show query in laravel
Use the toSql() method on a QueryBuilder instance.
DB::table('users')->toSql()
Example 4: echo query in laravel
DB::enableQueryLog();
dd(DB::getQueryLog());
DB::disableQueryLog();