private function resolveIDsfromESI(Collection $ids, $eseye)
    {

        // Finally, grab outstanding ids and resolve their names
        // using Esi.

        try {
            $eseye->setVersion('v3');
            $eseye->setBody($ids->flatten()->toArray());
            $names = $eseye->invoke('post', '/universe/names/');

            collect($names)->each(function ($name) {

                // Cache the name resolution for this id for a long time.
                cache([$this->prefix . $name->id => $name->name], carbon()->addCentury());
                $this->response[$name->id] = $name->name;

                UniverseName::firstOrCreate([
                    'entity_id' => $name->id,
                ], [
                    'name'      => $name->name,
                    'category'  => $name->category,
                ]);

            });

        } catch (\Exception $e) {
            // If this fails split the ids in half and try to self referential resolve the half_chunks
            // until all possible resolvable ids has processed.
            if ($ids->count() === 1) {
                // return a singleton unresolvable id as 'unknown'
                $this->response[$ids->first()] = trans('web::seat.unknown');
            } else {
                //split the chunk in two
                $half = ceil($ids->count() / 2);
                //keep on processing the halfs independently,
                //ideally one of the halfs will process just perfect
                $ids->chunk($half)->each(function ($half_chunk) use ($eseye) {

                    //this is a selfrefrencial call.
                    $this->resolveIDsfromESI($half_chunk, $eseye);
                });
            }

        }

    }
private function resolveIDsfromESI(Collection $ids, $eseye)
    {

        // Finally, grab outstanding ids and resolve their names
        // using Esi.

        try {
            $eseye->setVersion('v3');
            $eseye->setBody($ids->flatten()->toArray());
            $names = $eseye->invoke('post', '/universe/names/');

            collect($names)->each(function ($name) {

                // Cache the name resolution for this id for a long time.
                cache([$this->prefix . $name->id => $name->name], carbon()->addCentury());
                $this->response[$name->id] = $name->name;

                UniverseName::firstOrCreate([
                    'entity_id' => $name->id,
                ], [
                    'name'      => $name->name,
                    'category'  => $name->category,
                ]);

            });

        } catch (\Exception $e) {
            // If this fails split the ids in half and try to self referential resolve the half_chunks
            // until all possible resolvable ids has processed.
            if ($ids->count() === 1) {
                // return a singleton unresolvable id as 'unknown'
                $this->response[$ids->first()] = trans('web::seat.unknown');
            } else {
                //split the chunk in two
                $half = ceil($ids->count() / 2);
                //keep on processing the halfs independently,
                //ideally one of the halfs will process just perfect
                $ids->chunk($half)->each(function ($half_chunk) use ($eseye) {

                    //this is a selfrefrencial call.
                    $this->resolveIDsfromESI($half_chunk, $eseye);
                });
            }

        }

    }
private function resolveIDsfromESI ( Collection $ ids , $ eseye ) { // Finally, grab outstanding ids and resolve their names // using Esi. try { $ eseye -> setVersion ( 'v3' ) ; $ eseye -> setBody ( $ ids -> flatten ( ) -> toArray ( ) ) ; $ names = $ eseye -> invoke ( 'post' , '/universe/names/' ) ; collect ( $ names ) -> each ( function ( $ name ) { // Cache the name resolution for this id for a long time. cache ( [ $ this -> prefix . $ name -> id => $ name -> name ] , carbon ( ) -> addCentury ( ) ) ; $ this -> response [ $ name -> id ] = $ name -> name ; UniverseName :: firstOrCreate ( [ 'entity_id' => $ name -> id , ] , [ 'name' => $ name -> name , 'category' => $ name -> category , ] ) ; } ) ; } catch ( \ Exception $ e ) { // If this fails split the ids in half and try to self referential resolve the half_chunks // until all possible resolvable ids has processed. if ( $ ids -> count ( ) === 1 ) { // return a singleton unresolvable id as 'unknown' $ this -> response [ $ ids -> first ( ) ] = trans ( 'web::seat.unknown' ) ; } else { //split the chunk in two $ half = ceil ( $ ids -> count ( ) / 2 ) ; //keep on processing the halfs independently, //ideally one of the halfs will process just perfect $ ids -> chunk ( $ half ) -> each ( function ( $ half_chunk ) use ( $ eseye ) { //this is a selfrefrencial call. $ this -> resolveIDsfromESI ( $ half_chunk , $ eseye ) ; } ) ; } } }
Resolve given set of ids with the help of eseye client and ESI
using a boolean algorithm if one of the ids in the collection of ids
is invalid.
If name could be resolved, save the name to universe_names table.

@param \Illuminate\Support\Collection $ids
@param                                $eseye
Resolve given set of ids with the help of eseye client and ESI using a boolean algorithm if one of the ids in the collection of ids is invalid . If name could be resolved save the name to universe_names table .