/** * Shows the "configure" screen. * * @return \Illuminate\View\View */ public function index() { // Get the database drivers $drivers = $this->installer->getDatabaseDrivers(); $requirements = [new Requirements\ConfigPermissionsRequirement()]; $pass = true; foreach ($requirements as $requirement) { if (!$requirement->check()) { $pass = false; break; } } return view('platform/installer::configure', compact('drivers', 'requirements', 'pass')); }
/** * Prompts the user for the database credentials. * * @return void */ protected function askDatabaseDetails() { $this->output->writeln(<<<STEP <fg=yellow> *-----------------------------------------------* | | | Step #1: Configure Database | | | *-----------------------------------------------* </fg=yellow> STEP ); // Get all the available database drivers $drivers = $this->installer->getDatabaseDrivers(); // Ask the user to select the database driver $driver = $this->askDatabaseDriver($drivers); // Hold the database details $databaseData = []; // Loop through the selected driver fields foreach ($drivers[$driver] as $field => $config) { // Prepare the field name to avoid confusion $fieldName = $field === 'database' ? 'name' : $field; // Determine if the field output should be hidden $isHidden = $field === 'password'; // Prepare the question message if ($value = $config['value']) { $question = sprintf('<fg=green>Please enter the database</fg=green> [%s] (enter for [%s]): ', $fieldName, $config['value']); } else { $question = sprintf('<fg=green>Please enter the database</fg=green> [%s]: ', $fieldName); } // Prepare the question validator $validator = function ($answer) use($fieldName, $config) { if (!$answer && $config['rules'] === 'required') { throw new \RuntimeException("The database '{$fieldName}' field is required!"); } return $answer; }; // Ask the question to the user and store the answer $databaseData[$field] = $this->askQuestion($question, $config['value'], $isHidden, $validator); } $this->installer->setDatabaseData($driver, $databaseData); }