protected function refreshApplication(Foundation $foundation, Memory $memory): void
    {
        if (! $foundation->installed()) {
            $this->error('Abort as application is not installed!');

            return;
        }

        $this->call('extension:detect', ['--quiet' => true]);

        try {
            Collection::make($memory->get('extensions.active', []))
                ->keys()->each(function ($extension) {
                    $options = ['name' => $extension, '--force' => true];

                    $this->call('extension:refresh', $options);
                    $this->call('extension:update', $options);
                });

            $this->laravel->make('orchestra.extension.provider')->writeFreshManifest();
        } catch (PDOException $e) {
            // Skip if application is unable to make connection to the database.
        }
    }