Laravel Eloquent display query log

后端 未结 9 1821
萌比男神i
萌比男神i 2020-11-30 04:46
use App\\Order;

public function show(Order $order){

        $data = $order->all();
        return dd($order->getQueryLog());

Is there any w

9条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-30 05:13

    I know it's an old question, but it might help others that had the same issue I had.

    If you use other connection than the default one, you should specify it to get the query log properly.

    \DB::connection('YourConnection')->enableQueryLog();
    $test = MyModel::all();
    $queries = \DB::connection('YourConnection')->getQueryLog();
    dd($queries);
    

提交回复
热议问题