/** * Execute the command. */ public function handle() { $computers = Adldap::search()->computers()->get(); $i = 0; foreach ($computers as $computer) { if ($this->dispatch(new ImportComputer($computer))) { ++$i; } } $this->info("Successfully synchronized: {$i} computers."); }
/** * Execute the command. */ public function handle() { $users = Adldap::search()->users()->whereHas('mail')->whereObjectclass('user')->get(); $i = 0; if (count($users) > 0) { foreach ($users as $user) { if ($user instanceof User && $this->dispatch(new ImportUser($user))) { ++$i; } } } $this->info("Successfully synchronized: {$i} users."); }
/** * Returns true / false if the specified * computer exists in active directory. * * @return bool */ public function handle() { $computer = Adldap::search()->computers()->find($this->name); return $computer instanceof Computer; }