How to print query in laravel?

Laravel 7.2 routing with route group auth guard check with prefix

Hello to all, welcome to therichpost.com. In this post, I will tell you, How to print query in laravel? Like I always say that laravel is the best Mvc php framework.

Here is the working code to print query in laravel:
DB::enableQueryLog();
$user = DB::table('user')->where('email','!=','test')->get();
$query = DB::getQueryLog();
$query = end($query);
print_r($query);
die();
  or, you can try this one also:
$user = DB::table('user')->where('email','!=','test')->toSql();
dd($user);

 if you have any query related this post then please do ask.

 

Comments

One response to “How to print query in laravel?”

  1. jasmeen Avatar
    jasmeen

    Very helpful

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.