public function search($query, $lang = 'en', $limit = 10) 
    {    
        $client = new Client(); 

        $response = $client->get(self::API_ENDPOINT, [
            'query' => [
                'action' => 'wbsearchentities',
                'format' => 'json',
                'strictlanguage' => true,
                'language' => $lang,
                'uselang' => $lang,
                'search' => $query,
                'limit' => $limit,
                'props' => ''
            ]
        ]);

        $results = json_decode($response->getBody(), true);

        $data = isset($results['search']) ? $results['search'] : [];

        $collection = collect($data);

        $output = $collection->map(function($item) use ($lang) {
            return new SearchResult($item, $lang, 'api');
        });

        return $output;
    }
public function search($query, $lang = 'en', $limit = 10) 
    {    
        $client = new Client(); 

        $response = $client->get(self::API_ENDPOINT, [
            'query' => [
                'action' => 'wbsearchentities',
                'format' => 'json',
                'strictlanguage' => true,
                'language' => $lang,
                'uselang' => $lang,
                'search' => $query,
                'limit' => $limit,
                'props' => ''
            ]
        ]);

        $results = json_decode($response->getBody(), true);

        $data = isset($results['search']) ? $results['search'] : [];

        $collection = collect($data);

        $output = $collection->map(function($item) use ($lang) {
            return new SearchResult($item, $lang, 'api');
        });

        return $output;
    }
public function search ( $ query , $ lang = 'en' , $ limit = 10 ) { $ client = new Client ( ) ; $ response = $ client -> get ( self :: API_ENDPOINT , [ 'query' => [ 'action' => 'wbsearchentities' , 'format' => 'json' , 'strictlanguage' => true , 'language' => $ lang , 'uselang' => $ lang , 'search' => $ query , 'limit' => $ limit , 'props' => '' ] ] ) ; $ results = json_decode ( $ response -> getBody ( ) , true ) ; $ data = isset ( $ results [ 'search' ] ) ? $ results [ 'search' ] : [ ] ; $ collection = collect ( $ data ) ; $ output = $ collection -> map ( function ( $ item ) use ( $ lang ) { return new SearchResult ( $ item , $ lang , 'api' ) ; } ) ; return $ output ; }
Search entities by term

@param string $query
@param string $lang Language (default: en)
@param string $limit Max count of returning items (default: 10)

@return \Illuminate\Support\Collection Return collection of \Wikidata\SearchResult
Search entities by term