Loading…

How to enable query log in laravel 5?

Our first step should be

DB::connection()->enableQueryLog();

After our query it should be placed

$querylog = DB::getQueryLog();

After that it shou;ld be placed

dd($querylog)

Example

                                        

DB::connection()->enableQueryLog();

$result = User:where(['status' => 1])->get();

$log = DB::getQueryLog();

dd($log);

Suggest An Answer

No suggestions avaliable!

Latest post from Laravel 5 Interview Questions

Ask Question