public function findRinvexState($country, $needle)
    {
        $states = $this->findRinvex($country, 'divisions')->map(function ($state, $postal) {
            $state['postal'] = $postal;

            $state['name'] = $this->helper->fixUtf8($state['name']);

            return $state;
        });

        if ($states->isEmpty()) {
            return $states;
        }

        $state = $states->filter(function ($rinvexState) use ($needle) {
            return $rinvexState->postal == $needle->postal ||
                $rinvexState->name == $needle['name'] ||
                utf8_encode($rinvexState->name) == $needle['name'] ||
                $rinvexState->alt_names->contains($needle['name']) ||
                $rinvexState->alt_names->contains(function ($name) use ($needle) {
                    return $needle->alt_names->contains($name);
                });
        })->first();

        if (is_null($state)) {
            return coollect();
        }

        return coollect($state);
    }
public function findRinvexState($country, $needle)
    {
        $states = $this->findRinvex($country, 'divisions')->map(function ($state, $postal) {
            $state['postal'] = $postal;

            $state['name'] = $this->helper->fixUtf8($state['name']);

            return $state;
        });

        if ($states->isEmpty()) {
            return $states;
        }

        $state = $states->filter(function ($rinvexState) use ($needle) {
            return $rinvexState->postal == $needle->postal ||
                $rinvexState->name == $needle['name'] ||
                utf8_encode($rinvexState->name) == $needle['name'] ||
                $rinvexState->alt_names->contains($needle['name']) ||
                $rinvexState->alt_names->contains(function ($name) use ($needle) {
                    return $needle->alt_names->contains($name);
                });
        })->first();

        if (is_null($state)) {
            return coollect();
        }

        return coollect($state);
    }
public function findRinvexState ( $ country , $ needle ) { $ states = $ this -> findRinvex ( $ country , 'divisions' ) -> map ( function ( $ state , $ postal ) { $ state [ 'postal' ] = $ postal ; $ state [ 'name' ] = $ this -> helper -> fixUtf8 ( $ state [ 'name' ] ) ; return $ state ; } ) ; if ( $ states -> isEmpty ( ) ) { return $ states ; } $ state = $ states -> filter ( function ( $ rinvexState ) use ( $ needle ) { return $ rinvexState -> postal == $ needle -> postal || $ rinvexState -> name == $ needle [ 'name' ] || utf8_encode ( $ rinvexState -> name ) == $ needle [ 'name' ] || $ rinvexState -> alt_names -> contains ( $ needle [ 'name' ] ) || $ rinvexState -> alt_names -> contains ( function ( $ name ) use ( $ needle ) { return $ needle -> alt_names -> contains ( $ name ) ; } ) ; } ) -> first ( ) ; if ( is_null ( $ state ) ) { return coollect ( ) ; } return coollect ( $ state ) ; }
Find the Rinvex state.

@param $country
@param \PragmaRX\Coollection\Package\Coollection $needle
@return null|Coollection
Find the Rinvex state .