Open asundust opened 3 years ago
Hey, I just ran into the same question:
If you have registered an EventDispatcher on the Capsule Manager you can register an event listener:
$eventDispatcher = new Dispatcher(new Container);
$capsule->setEventDispatcher($eventDispatcher);
# or alternatively if the capsule is defined already
$eventDispatcher = $capsule->getEventDispatcher();
$eventDispatcher->listen(\Illuminate\Database\Events\QueryExecuted::class,
function (\Illuminate\Database\Events\QueryExecuted $query) {
// $query->sql;
// $query->bindings;
// $query->time;
}
);
hth
How to write to the log using DB::listen() ?