Exemplo n.º 1
0
 /**
  * @param StreamsHasInstalled $event
  */
 public function handle(StreamsHasInstalled $event)
 {
     $installers = $event->getInstallers();
     $installers->add(new Installer('Creating the user role.', function () {
         $user = $this->users->findByUsername(env('ADMIN_USERNAME'));
         if (!($role = $this->roles->findBySlug('user'))) {
             $role = $this->roles->create(['en' => ['name' => 'User'], 'slug' => 'user']);
         }
         if (!$user->hasRole($role)) {
             $user->roles()->attach($role);
         }
     }));
 }
Exemplo n.º 2
0
 /**
  * Handle the command.
  *
  * @param StreamsHasInstalled $event
  */
 public function handle(StreamsHasInstalled $event)
 {
     $installers = $event->getInstallers();
     $installers->add(new Installer('Creating the admin user.', function () {
         $credentials = ['display_name' => 'Administrator', 'email' => env('ADMIN_EMAIL'), 'username' => env('ADMIN_USERNAME'), 'password' => env('ADMIN_PASSWORD')];
         if ($user = $this->users->findByUsername(env('ADMIN_USERNAME'))) {
             $user->email = env('ADMIN_EMAIL');
             $user->password = env('ADMIN_PASSWORD');
             $this->users->save($user);
         } else {
             $user = $this->users->create($credentials);
         }
         $this->activator->force($user);
     }));
 }