Show queries in laravel

 

Laravel provides a database query builder. To see the query use toSql() in laravel.

 

$result = DB::table(‘users’)
->where(‘username’, ‘like’, ‘%admin%’)
->toSql() // to see the query which is executed
//  ->get()->toArray();  to get results
dd($result)