コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
ファイル: Init.php プロジェクト: inoplate/account
 /**
  * Handle incoming console command
  * 
  * @return void
  */
 public function handle()
 {
     $this->truncateTable();
     $this->initRole();
     $administrator = $this->roleRepository->findByName('Administrator');
     $this->attachPermissionToRole($administrator);
     $this->initUser($administrator);
 }
コード例 #4
0
ファイル: RolenameIsUnique.php プロジェクト: inoplate/account
 /**
  * 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;
 }
コード例 #5
0
 /**
  * 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)]);
 }
コード例 #6
0
 /**
  * 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);
 }
コード例 #7
0
ファイル: UsersController.php プロジェクト: inoplate/account
 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'));
 }