DB::connection()->enableQueryLog(); //enable query log
$data = $order->all(); //query execute
$queries = DB::getQueryLog(); //get query
return dd($queries); //show query
public function show(Order $order){
DB::connection()->enableQueryLog();
$data = $order->all();
$queries = DB::getQueryLog();
return dd($queries);
}
namespace AppProviders;
use DB;
use Log;
use IlluminateSupportServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
DB::listen(function($query) {
Log::info(
$query->sql,
$query->bindings,
$query->time
);
});
}
// ...
}
import DB with this line first,
use IlluminateSupportFacadesDB;
check whethe the serviceprovider is added in the providers array in config/app.php
if no then check whether the service provider class is the correct location and
include the serivce provider in the providers array in config.app.php
check whethe the serviceprovider is added in the providers array in config/app.php
if no then check whether the service provider class is the correct location and
include the serivce provider in the providers array in config.app.php