Ejemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $groups = $this->option('groups');
     $email = $this->option('email');
     $fullname = $this->option('fullname');
     if ($groups) {
         $this->info("> Groups \t: " . $groups);
     }
     if ($email) {
         $this->info("> Email \t: " . $email);
     }
     if ($fullname) {
         $this->info("> Fullname \t: " . $fullname);
     }
     $headers = ['ID', 'Fullname', 'Email', 'Groups'];
     if ($email != '') {
         $users = User::select(['id', 'fullname', 'email'])->where('email', 'like', '%' . $email . '%')->get()->load('groups');
     } else {
         $users = User::all(['id', 'fullname', 'email'])->load('groups');
     }
     $op = [];
     foreach ($users as $user) {
         $op[] = ['id' => $user->id, 'fullname' => $user->fullname, 'email' => $user->email, 'groups' => implode($user->groups->pluck('title')->toArray(), ",")];
     }
     $this->table($headers, $op);
 }