コード例 #1
0
ファイル: PermCreate.php プロジェクト: linearsoft/entrust-cli
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $name = $this->argument('name');
     $perm = $this->loadPerm($name, true);
     if ($perm != null) {
         return;
     }
     $displayName = $this->argument('display_name');
     $description = $this->argument('description');
     Permission::create([Permission::PROPERTY_NAME => $name, Permission::PROPERTY_DISPLAY => $displayName, Permission::PROPERTY_DESC => $description]);
     $this->info("Successfully created the permission '{$name}'.");
 }
コード例 #2
0
 /**
  * Loads Permission based upon name
  *
  * @param $name
  * @param bool $failOnSuccess
  * @return null|Permission
  */
 protected function loadPerm($name, $failOnSuccess = false)
 {
     $perm = Permission::query()->where(Permission::PROPERTY_NAME, $name)->first();
     if ($perm == null) {
         if ($failOnSuccess) {
             return null;
         }
         $this->error("The Entrust permission '{$name}' does not exist.");
     } elseif ($failOnSuccess) {
         $this->error("The Entrust permission '{$name}' already exists.");
     }
     return $perm;
 }
コード例 #3
0
ファイル: PermList.php プロジェクト: linearsoft/entrust-cli
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $headers = ['Name', 'Display Name', 'Description', 'Id'];
     $roles = Permission::all([Permission::PROPERTY_NAME, Permission::PROPERTY_DISPLAY, Permission::PROPERTY_DESC, Permission::PROPERTY_KEY])->toArray();
     $this->table($headers, $roles);
 }