Exemplo n.º 1
0
 public function test_users_can_be_constrained_to_a_model_blanket_ability()
 {
     $bouncer = $this->bouncer($user = User::create());
     $bouncer->allow('admin')->to('ban', User::class);
     $bouncer->allow('moderator')->to('ban', $user);
     $roles = Role::whereCan('ban', User::class)->get();
     $this->assertCount(1, $roles);
     $this->assertEquals('admin', $roles->first()->name);
 }
Exemplo n.º 2
0
 /**
  * Assign the role to the users with the given ids.
  *
  * @param  \JonaGoldman\Bouncer\Database\Role  $role
  * @param  array  $ids
  * @return void
  */
 protected function assignRole(Role $role, array $ids)
 {
     $existing = $role->users()->whereIn('id', $ids)->lists('id')->all();
     $ids = array_diff($ids, $existing);
     $role->users()->attach($ids);
 }