dimanche 3 janvier 2016

display last query in laravel 5

I use :

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

But it's not working.

My service is like 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 run it, query does not appear

The result is like this :

array(0) {
}

How to get the query executed in Laravel 5?

Thank you very much



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire