示例#1
0
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     // disable foreign key constraints
     // Reset table
     DB::table('users')->truncate();
     // Reset table
     DB::table('user_details')->truncate();
     $admin_account = Config::get('cms::settings.admin_account');
     $admin_settings = array('role_id' => 1, 'lang' => Config::get('cms::settings.language'), 'editor' => 0, 'is_active' => 1);
     $admin_user = array_merge($admin_account, $admin_settings);
     $admin_user['password'] = Hash::make($admin_user['password']);
     $admin = User::create($admin_user);
     UserDetail::create(array('user_id' => $admin->id));
     // RANDOM 50 USERS
     // Faker data
     $faker = Faker\Factory::create();
     for ($i = 1; $i <= 50; $i++) {
         $user_settings = array('role_id' => 4, 'username' => $faker->username, 'email' => $faker->email, 'password' => Hash::make($faker->word), 'lang' => Config::get('cms::settings.language'), 'editor' => 0, 'is_active' => 1);
         $user = User::create($user_settings);
         $details = array('firstname' => $faker->firstname, 'lastname' => $faker->lastname, 'gender' => $faker->randomElement(array('m', 'f')), 'city' => $faker->city, 'bio' => $faker->text, 'birth_date' => $faker->date('Y-m-d', '-18 years'));
         $user->details()->create($details);
     }
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     // enable foreign key constraints
 }
示例#2
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     // Calling migration for pongocms package
     $this->call('migrate', array('--package' => 'pongocms/cms'));
     // Change Auth model
     $this->call('pongo:change_auth_model');
     // Move themes folder
     $this->call('pongo:move_themes_folder');
     // Setup system roles
     $roles = \Config::get('cms::system.roles');
     foreach ($roles as $name => $level) {
         $role = array('name' => $name, 'level' => $level);
         \DB::table('roles')->insert($role);
     }
     // Setup admin user
     $admin_account = \Config::get('cms::settings.admin_account');
     $admin_settings = array('role_id' => 1, 'lang' => \Config::get('cms::settings.language'), 'editor' => 0, 'is_active' => 1);
     $admin_user = array_merge($admin_account, $admin_settings);
     $admin_user['password'] = \Hash::make($admin_user['password']);
     $admin = User::create($admin_user);
     UserDetail::create(array('user_id' => $admin->id));
     $this->info('PongoCMS has been successfully set up!');
     return;
 }