예제 #1
0
 public function finish(Application $app, DatabaseManager $manager)
 {
     $response = $manager->migrateAndSeed();
     if ($response['status'] == 'danger') {
         return redirect(route('installer::database'))->withErrors(['message' => $response['message']])->withInput();
     }
     $installer = app('installer');
     $fm = $installer->getFileManager();
     if (!$fm->create(app('installer')->config('last_version'))) {
         return redirect(route('installer::database'))->withErrors(['exception' => Lang::get('installer::installer.database.error')])->withInput();
     }
     return redirect(route('installer::finish'))->with($response);
 }
예제 #2
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire(DatabaseManager $dbmanager)
 {
     $currentVersion = $this->laravel['installer']->getFileManager()->getVersion();
     $last_version = $this->laravel['installer']->config('last_version');
     $continue = $this->confirm(sprintf('Your are currently running version %s and the latest available version is %s continue upgrade', $currentVersion, $last_version), 'yes');
     if (!$continue) {
         return;
     }
     $this->call('vendor:publish');
     $response = $dbmanager->updateDatabaseAndSeedTables();
     if ($response['status'] == 'danger') {
         return $this->error('Error: ' . $response['message'] . '!');
     }
     $fm = $this->laravel['installer']->getFileManager();
     if (!$fm->create(app('installer')->config('last_version'))) {
         return $this->error('Error: ' . Lang::get('installer::installer.database.error') . '!');
     }
     return $this->info('Upgrade is completed!');
 }
 public function post(Application $app, DatabaseRequest $request, DatabaseManager $manager)
 {
     $driver = $manager->setConfig($app, $request);
     try {
         DB::connection($driver);
     } catch (\Exception $e) {
         return redirect(route('installer::database'))->withErrors(['exception' => $e->getMessage()])->withInput();
     }
     try {
         $manager->writeConfig();
     } catch (\Exception $e) {
         return redirect(route('installer::database'))->withErrors(['exception' => $e->getMessage()])->withInput();
     }
     $response = $manager->migrateAndSeed();
     if ($response['status'] == 'danger') {
         return redirect(route('installer::database'))->with($response)->withInput();
     }
     $installer = app('installer');
     $fm = $installer->getFileManager();
     if (!$fm->create(app('installer')->config('last_version'))) {
         return redirect(route('installer::database'))->withErrors(['exception' => Lang::get('installer::installer.database.error')])->withInput();
     }
     return redirect(route('installer::finish'))->with($response);
 }
예제 #4
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire(RequirementsChecker $requirement, PermissionsChecker $permision, DatabaseManager $dbmanager)
 {
     $requirements = $requirement->check(config('installer.requirements'));
     $rows = [];
     if (isset($requirements['requirements']) && is_array($requirements['requirements'])) {
         foreach ($requirements['requirements'] as $k => $v) {
             $rows[] = [$k, $v ? 'Ok' : 'Error'];
         }
     }
     if ($rows) {
         $this->table(['Requirements', 'Status'], $rows);
         if (isset($requirements['error']) && $requirements['error']) {
             return $this->error('Error: Missing requirements!');
         }
         $continue = $this->confirm('Continue installation', 'yes');
         if (!$continue) {
             return;
         }
     }
     $permissions = $permision->check(config('installer.permissions'));
     $rows = [];
     if (isset($permissions['permissions']) && is_array($permissions['permissions'])) {
         foreach ($permissions['permissions'] as $v) {
             $rows[] = [$v['folder'], $v['permission']];
         }
     }
     if ($rows) {
         $this->table(['Folder/File', 'Is Writable'], $rows);
         if (isset($permissions['error']) && $permissions['error']) {
             return $this->error('Error: Missing permissions!');
         }
         $continue = $this->confirm('Continue installation', 'yes');
         if (!$continue) {
             return;
         }
     }
     $host = $this->ask('Set database host', 'localhost');
     $username = $this->ask('Set database username', 'root');
     $password = $this->ask('Set database password', '');
     $name = $this->ask('Set database name', '');
     $driver = $dbmanager->setConfig($this->laravel, ['host' => $host, 'database' => $name, 'username' => $username, 'password' => $password]);
     try {
         with(new ConnectionFactory($this->laravel))->make(config('database.connections.' . $driver), $driver)->getPdo();
     } catch (\Exception $e) {
         return $this->error('Error: ' . $e->getMessage() . '!');
     }
     try {
         $dbmanager->writeConfig($this->laravel, ['host' => $host, 'database' => $name, 'username' => $username, 'password' => $password]);
     } catch (\Exception $e) {
         return $this->error('Error: ' . $e->getMessage() . '!');
     }
     $this->call('vendor:publish');
     $response = $dbmanager->migrateAndSeed();
     if ($response['status'] == 'danger') {
         return $this->error('Error: ' . $response['message'] . '!');
     }
     $installer = $this->laravel['installer'];
     $fm = $installer->getFileManager();
     if (!$fm->create($this->laravel['installer']->config('last_version'))) {
         return $this->error('Error: ' . Lang::get('installer::installer.database.error') . '!');
     }
     return $this->info('Installation is completed!');
 }