Laravel Query Log – Learn How To Enable Query Log In Laravel & Last Executed Query

Enable Query Log In Laravel & Last Executed Query

Method name as enableQueryLog  will help you to enable query log in laravel

DB::enableQueryLog();
$arr_user = DB::table('users')->select('name', 'email as user_email')->get();
dd(DB::getQueryLog());

Last executed query in Laravel

$queries = DB::getQueryLog();
$last_query = end($queries); // Last executed query

You may also like...

Leave a Reply

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