Пример #1
0
 public function runUpdate()
 {
     if (Capsule::schema()->hasTable('settings')) {
         $updateVersion = SettingModel::where('name', 'update_version')->first();
         if ($updateVersion && $updateVersion->value == $this->app['version']) {
             return $this->app->redirect('/');
         }
     }
     $s = new Seeder($this->app, $this->app['projects.creator']);
     $s->seedTemplates();
     $s->seedLibraries();
     if (SettingModel::where('name', 'update_version')->first()) {
         SettingModel::where('name', 'update_version')->update(array('value' => $this->app['version']));
     } else {
         SettingModel::insert(array('name' => 'update_version', 'value' => $this->app['version']));
     }
     return $this->app->redirect('/');
 }
Пример #2
0
 /**
  * Reset database by truncating tables and re-seeding.
  * 
  * @return Response
  */
 public function reset()
 {
     if ($_SERVER['REMOTE_ADDR'] !== $_SERVER['SERVER_ADDR']) {
         return new Response('You don\'t have permissions to do that.', 403);
     }
     DB::table('folders')->truncate();
     DB::table('groups')->truncate();
     DB::table('images')->truncate();
     DB::table('images_folders')->truncate();
     DB::table('libraries')->truncate();
     DB::table('pages')->truncate();
     DB::table('pages_libraries')->truncate();
     DB::table('projects')->truncate();
     DB::table('templates')->truncate();
     DB::table('themes')->truncate();
     DB::table('users_projects')->truncate();
     $this->emptyFolders();
     $this->seeder->seed();
     $this->seeder->seedDemoProjects();
     file_put_contents($this->lastResetPath, '<?php return ' . Carbon::now()->timestamp . ';');
     return new Response('Reset database successfully.', 200);
 }