app->make('db'); $callback = function () { if (RefreshDatabaseState::$lazilyRefreshed) { return; } RefreshDatabaseState::$lazilyRefreshed = true; if (property_exists($this, 'mockConsoleOutput')) { $shouldMockOutput = $this->mockConsoleOutput; $this->mockConsoleOutput = false; } $this->baseRefreshDatabase(); if (property_exists($this, 'mockConsoleOutput')) { $this->mockConsoleOutput = $shouldMockOutput; } }; foreach ($this->connectionsToTransact() as $connection) { $database->connection($connection)->beforeStartingTransaction($callback); $database->connection($connection)->beforeExecuting($callback); } $this->beforeApplicationDestroyed(function () { RefreshDatabaseState::$lazilyRefreshed = false; }); } }