public function boot() { /* @var $db \Illuminate\Database\DatabaseManager */ $db = $this->app['db']; $db->listen(function ($sql, $bindings, $time, $dbName) use($db) { $connection = $db->connection($dbName); $this->queries[] = ['sql' => $sql, 'bindings' => $bindings, 'time' => $time]; if (starts_with($sql, 'select')) { $this->_explainAndShowIndex($connection, $sql, $bindings); } }); $this->app->terminating(function () { $this->analyze(); }); }
/** * Execute the job. * * @param \Illuminate\Contracts\Foundation\Application $app * @param \Illuminate\Contracts\Console\Kernel $kernel * * @return void */ public function handle(Application $app, Kernel $kernel) { if (!$app->routesAreCached()) { return; } $app->terminating(function () use($kernel) { $kernel->call('route:cache'); }); }