use App\\Order;
public function show(Order $order){
$data = $order->all();
return dd($order->getQueryLog());
Is there any w
Working on 5.6, something like this in AppServiceProvider::boot()
// Log all DB SELECT statements
// @codeCoverageIgnoreStart
if (!app()->environment('testing') && config('app.log_sql')) {
DB::listen(function ($query) {
if (preg_match('/^select/', $query->sql)) {
Log::info('sql: ' . $query->sql);
// Also available are $query->bindings and $query->time.
}
});
}
Then in config/app.php, just so it's easy to enable/disable from amending the .env
'log_sql' => env('LOG_SQL'),
All credit to: https://arjunphp.com/laravel-5-5-log-eloquent-queries/
And this can be parsed for unique queries with:
grep ") sql:" laravel.log | sed -e "s#.*select\(.*\)\[\]#select\1#" | sort -u