Example #1
0
 /**
  * Adds the user to the given group.
  *
  * @param \Cartalyst\Sentry\Groups\GroupInterface $group
  *
  * @return bool
  */
 public function addGroup(GroupInterface $group)
 {
     if (Credentials::check()) {
         RevisionRepository::create(['revisionable_type' => get_class($this), 'revisionable_id' => $this->getKey(), 'key' => 'added_group', 'old_value' => null, 'new_value' => $group->getName(), 'user_id' => Credentials::getUser()->id]);
     }
     return parent::addGroup($group);
 }
 /**
  * Adds the array of groups to the specified user.
  *
  * @param \Cartalyst\Sentry\Users\Eloquent\User $user
  * @param array                                 $groups
  *
  * @return bool
  */
 private function addGroupsToUser($user, array $groups = [])
 {
     if (count($groups) > 0) {
         foreach ($groups as $group) {
             try {
                 $group = Sentry::findGroupByName($group);
                 $user->addGroup($group);
             } catch (GroupNotFoundException $e) {
             }
         }
         return true;
     }
     return false;
 }