/**
  * Retrieve role and ensure role is exist
  * 
  * @param  mixed $id
  * @return AccountDomainModels\Role
  */
 protected function retrieveRole($id)
 {
     $role = $this->roleRepository->findById($id);
     if (is_null($role)) {
         throw new ValueNotFoundException("[{$id}] is not valid role id");
     }
     return $role;
 }
 /**
  * Build roles from id of roles
  * 
  * @param  array $idOfRoles
  * @return array
  */
 protected function buildRoles($idOfRoles)
 {
     $roles = [];
     foreach ($idOfRoles as $id) {
         $roles[] = $this->roleRepository->findById($id);
     }
     return $roles;
 }
Exemple #3
0
 /**
  * Handle incoming console command
  * 
  * @return void
  */
 public function handle()
 {
     $this->truncateTable();
     $this->initRole();
     $administrator = $this->roleRepository->findByName('Administrator');
     $this->attachPermissionToRole($administrator);
     $this->initUser($administrator);
 }
 /**
  * Determine if specification was satisfied by given candidate
  * 
  * @param  SpecificationCandidate $candidate
  * @return boolean
  */
 public function isSatisfiedBy(SpecificationCandidate $candidate)
 {
     if ($user = $this->roleRepository->findByName($candidate->value())) {
         if (!$user->id()->equal($this->id)) {
             return false;
         }
     }
     return true;
 }
 /**
  * Handle role creation
  * 
  * @param  CreateNewRole $command
  * @return void
  */
 public function handle(CreateNewRole $command)
 {
     $name = new FoundationDomainModels\Name($command->name);
     $description = new FoundationDomainModels\Description($command->description);
     $id = $this->roleRepository->nextIdentity();
     $this->ensureNameIsUnique($name);
     $role = new AccountDomainModels\Role($id, $name, $description);
     $this->roleRepository->save($role);
     $this->events->fire([new RoleWasCreated($role)]);
 }
 /**
  * Handle incoming console command
  * 
  * @return void
  */
 public function handle()
 {
     $roleName = $this->ask('Role name?');
     $role = $this->roleRepository->findByName($roleName);
     if (is_null($role)) {
         $this->error('Rolename [' . $roleName . '] doesn\'t exist ');
     }
     $this->info('Clear attached permissions');
     $this->resetTable($role);
 }
Exemple #7
0
 public function getUpdate(RoleRepository $roleRepository, $id)
 {
     $user = $this->userRepository->findById($id);
     $roles = $roleRepository->all();
     if (is_null($user)) {
         abort(404);
     } else {
         $user = $user->toArray();
     }
     return $this->getResponse('inoplate-account::users.update', compact('user', 'roles'));
 }