コード例 #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Permission::truncate();
     Permission::reguard();
     $sets = $this->permissions();
     foreach ($sets as $set) {
         $permissionSet = PermissionSet::create($set);
         foreach ($set['permissions'] as $permission) {
             $permissionSet->permissions()->save(Permission::create($permission));
         }
     }
 }
コード例 #2
0
ファイル: Membership.php プロジェクト: atorscho/membership
 /**
  * Register Membership's permissions with Laravel's Gate.
  *
  * @param \Illuminate\Contracts\Auth\Access\Gate $gate
  */
 public function registerPermissions(\Illuminate\Contracts\Auth\Access\Gate $gate)
 {
     // Register permissions only if the table exists
     if (!\Schema::hasTable('permissions')) {
         return;
     }
     $permissions = $this->permissions->all();
     foreach ($permissions as $permission) {
         $gate->define($permission->handle, function ($user) use($permission) {
             return $user->can($permission->handle);
         });
     }
 }