How to display the last request in laravel 5?

I use:

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

But it does not work.

My service is this:

 public function dataCustomerList($param) { $status = $param['status_sort']; $gender = $param['gender']; $published = $param['published']; if($published=='NO'){ $published_check = 'NO'; $published = 0; } else if($published=='YES'){ $published_check = 'YES'; $published = 1; } DB::connection()->enableQueryLog(); $customer = customer::paginate(10); if(!empty($status)) { // die($status); $customer = customer::where('tb_customer.customer_status', '=', $status)->paginate(10); } if (!empty($gender)) { $customer = customer::where('tb_customer.gender', '=', $gender)->paginate(10); } if (!empty($published_check)) { $customer = customer::where('tb_customer.published', '=', $published)->paginate(10); } var_dump(DB::getQueryLog()); return $customer; } 

When I launched it, the request will not appear

The result is as follows:

 array(0) { } 

How to execute a request in Laravel 5?

Thank you very much

+5
source share
1 answer

You can listen for event requests in DB :

 DB::listen(function($sql, $bindings, $time) { var_dump($sql); }); 
+3
source

Source: https://habr.com/ru/post/1239711/


All Articles