Exemple #1
0
 /**
  * Construct a collection of Result objects based on the hits
  * in the Elasticsearch response
  *
  * @param Response $response
  */
 public function __construct(Response $response)
 {
     $this->response = $response;
     parent::__construct(array_map(function ($hit) {
         return new Result($hit);
     }, $this->response->getHits()));
 }
Exemple #2
0
 /**
  * Construct a collection of Eloquent models based on the search result
  *
  * @access public
  * @param Response $response
  */
 public function __construct(Response $response)
 {
     $this->response = $response;
     $ids = array_map(function ($hit) {
         return $hit['_id'];
     }, $this->response->getHits());
     $model = $response->getModel();
     parent::__construct($model::whereIn('id', $ids)->get()->toArray());
 }