Exemplo n.º 1
0
 /**
  * Get the results for the given query.
  *
  * @param string|array|\Spatie\SearchIndex\Query\Algolia\SearchQuery $query
  *
  * @return mixed
  */
 public function getResults($query)
 {
     $parameters = [];
     if (is_object($query) && $query instanceof SearchQuery) {
         $query = $query->toArray();
     }
     if (is_array($query)) {
         $collection = new Collection($query);
         $query = $collection->pull('query', '');
         $parameters = $collection->toArray();
     }
     return $this->index->search($query, $parameters);
 }
Exemplo n.º 2
0
 public function it_can_get_search_results_using_an_array_without_a_query_key(\AlgoliaSearch\Index $index)
 {
     $query = ['param1' => 'yes', 'param2' => 'no'];
     $index->search('', ['param1' => 'yes', 'param2' => 'no'])->shouldBeCalled();
     $this->getResults($query);
 }