コード例 #1
0
ファイル: MakeRole.php プロジェクト: torome/defender
 /**
  * Create role.
  *
  * @param string $roleName
  *
  * @return \Artesaos\Defender\Role
  */
 protected function createRole($roleName)
 {
     // No need to check is_null($role) as create() throwsException
     $role = $this->roleRepository->create($roleName);
     $this->info('Role created successfully');
     return $role;
 }
コード例 #2
0
ファイル: MakePermission.php プロジェクト: torome/defender
 /**
  * @param \Artesaos\Defender\Permission $permission
  * @param string                           $roleName
  */
 protected function attachPermissionToRole($permission, $roleName)
 {
     // Check if role exists
     if ($role = $this->roleRepository->findByName($roleName)) {
         $role->attachPermission($permission);
         $this->info('Permission attached successfully to role');
     } else {
         $this->error('Not possible to attach permission. Role not found');
     }
 }
コード例 #3
0
ファイル: Defender.php プロジェクト: renanpro03/defender
 /**
  * Create a new role.
  * Uses a repository to actually create the role.
  *
  * @param string $roleName
  *
  * @return \Artesaos\Defender\Role
  */
 public function createRole($roleName)
 {
     return $this->roleRepository->create($roleName);
 }
コード例 #4
0
ファイル: Defender.php プロジェクト: robertfsousa/defender
 /**
  * Create a new role.
  * Uses a repository to actually create the role.
  *
  * @param string $roleName
  * @param string $readableName
  * @param string $type
  *
  * @return \Artesaos\Defender\Role
  */
 public function createRole($roleName, $readableName = null, $type = 'business')
 {
     return $this->roleRepository->create($roleName, $readableName, $type);
 }
コード例 #5
0
ファイル: DefenderSpec.php プロジェクト: torome/defender
 public function it_should_throw_an_exception_when_the_given_role_already_exists(RoleRepository $roleRepository)
 {
     $roleRepository->create('foo')->shouldBeCalled()->willThrow(new \Exception());
     $this->shouldThrow('\\Exception')->duringCreateRole('foo');
 }
コード例 #6
0
 /**
  * Create a new role
  *
  * @param Request $request
  * @return array
  */
 public function store(Request $request)
 {
     $name = $request->get('name');
     $newRole = $this->rolesRepository->create($name);
     return response()->json($newRole, 201);
 }
コード例 #7
0
 /**
  * Get a role by id
  *
  * @param $id role_id
  * @return \Illuminate\Http\JsonResponse
  */
 public function show($id)
 {
     $role = $this->roleRepository->findById($id);
     return response()->json($role, 200);
 }