private function presentUsersToSelect($results)
    {
        $this->info($results->count() . ' result(s) were returned');

        if ($results->count() < 1) {
            die();
        }

        if ($results->count() == 1) {
            $detail = [];
            $keys = array_keys($results->toArray()[0]);
            foreach ($keys as $key) {
                $detail[] = $key .':'. $results->first()->{$key};
            }
            $this->info("[".$results->first()->id."] : " . implode(', ', $detail));

            $this->info("User selected: [".$results->first()->id."]");
            $this->selectedUser = $results->first()->id;
        }
        
        if ($results->count() > 1) {
            $ids = $results->pluck('id')->toArray();
            $keys = array_keys($results->toArray()[0]);

            foreach($results as $result) {
                $detail = [];
                foreach ($keys as $key) {
                    $detail[] = $key .':'. $result->{$key};
                }

                $this->info("[$result->id] : " . implode(', ', $detail));
            }

            while($this->selectedUser == 0) {
                $selectUser = $this->ask('Which user do you wish to update?');
                if (in_array($selectUser, $ids)) {
                    $this->info("User selected: [".$selectUser."]");
                    $this->selectedUser = $selectUser;
                }
            }
        }
    }
private function presentUsersToSelect($results)
    {
        $this->info($results->count() . ' result(s) were returned');

        if ($results->count() < 1) {
            die();
        }

        if ($results->count() == 1) {
            $detail = [];
            $keys = array_keys($results->toArray()[0]);
            foreach ($keys as $key) {
                $detail[] = $key .':'. $results->first()->{$key};
            }
            $this->info("[".$results->first()->id."] : " . implode(', ', $detail));

            $this->info("User selected: [".$results->first()->id."]");
            $this->selectedUser = $results->first()->id;
        }
        
        if ($results->count() > 1) {
            $ids = $results->pluck('id')->toArray();
            $keys = array_keys($results->toArray()[0]);

            foreach($results as $result) {
                $detail = [];
                foreach ($keys as $key) {
                    $detail[] = $key .':'. $result->{$key};
                }

                $this->info("[$result->id] : " . implode(', ', $detail));
            }

            while($this->selectedUser == 0) {
                $selectUser = $this->ask('Which user do you wish to update?');
                if (in_array($selectUser, $ids)) {
                    $this->info("User selected: [".$selectUser."]");
                    $this->selectedUser = $selectUser;
                }
            }
        }
    }
private function presentUsersToSelect ( $ results ) { $ this -> info ( $ results -> count ( ) . ' result(s) were returned' ) ; if ( $ results -> count ( ) < 1 ) { die ( ) ; } if ( $ results -> count ( ) == 1 ) { $ detail = [ ] ; $ keys = array_keys ( $ results -> toArray ( ) [ 0 ] ) ; foreach ( $ keys as $ key ) { $ detail [ ] = $ key . ':' . $ results -> first ( ) -> { $ key } ; } $ this -> info ( "[" . $ results -> first ( ) -> id . "] : " . implode ( ', ' , $ detail ) ) ; $ this -> info ( "User selected: [" . $ results -> first ( ) -> id . "]" ) ; $ this -> selectedUser = $ results -> first ( ) -> id ; } if ( $ results -> count ( ) > 1 ) { $ ids = $ results -> pluck ( 'id' ) -> toArray ( ) ; $ keys = array_keys ( $ results -> toArray ( ) [ 0 ] ) ; foreach ( $ results as $ result ) { $ detail = [ ] ; foreach ( $ keys as $ key ) { $ detail [ ] = $ key . ':' . $ result -> { $ key } ; } $ this -> info ( "[$result->id] : " . implode ( ', ' , $ detail ) ) ; } while ( $ this -> selectedUser == 0 ) { $ selectUser = $ this -> ask ( 'Which user do you wish to update?' ) ; if ( in_array ( $ selectUser , $ ids ) ) { $ this -> info ( "User selected: [" . $ selectUser . "]" ) ; $ this -> selectedUser = $ selectUser ; } } } }
Get the user to select the correct user to update

@param $results
Get the user to select the correct user to update