laravel query to sql code example
Example 1: print last sql query laravel
DB::enableQueryLog(); // Enable query log
// Your Eloquent query executed by using get()
dd(DB::getQueryLog()); // Show results of log
Example 2: laravel to sql
DB::table('users')->toSql()
Example 3: show query in laravel
Use the toSql() method on a QueryBuilder instance.
DB::table('users')->toSql()
Example 4: laravel db query
$users = DB::table('users')
->where('votes', '>', 100)
->orWhere(function($query) {
$query->where('name', 'Abigail')
->where('votes', '>', 50);
})
->get();