Adldap\Models\Group::getMembers PHP Method

getMembers() public method

https://msdn.microsoft.com/en-us/library/ms677097(v=vs.85).aspx
public getMembers ( ) : Collection
return Illuminate\Support\Collection
    public function getMembers()
    {
        $members = $this->getMembersFromAttribute($this->schema->member());
        if (count($members) === 0) {
            $members = $this->getPaginatedMembers();
        }
        return $this->newCollection($members);
    }

Usage Example

Example #1
0
 /**
  * Execute the job.
  *
  * @return Role
  */
 public function handle()
 {
     $label = $this->group->getName();
     $name = str_slug($label);
     // We'll create the role if it doesn't exist already.
     $role = Role::firstOrCreate(compact('name', 'label'));
     // We'll double check that it was successfully retrieved / created.
     if ($role instanceof Role) {
         // Retrieve the members from the AD group.
         $members = $this->group->getMembers();
         foreach ($members as $member) {
             // Import users that may not already be apart of our local DB.
             $user = $this->dispatch(new ImportUser($member));
             // Make sure the user isn't already apart of the role.
             $exists = $role->users()->find($user->id);
             if (!$exists) {
                 // Attach the user to the role if they
                 // aren't currently a member.
                 $role->users()->save($user);
             }
         }
         return $role;
     }
     return false;
 }