/** * PlasticPaginator constructor. * * @param PlasticResult $result * @param int $limit * @param int $page */ public function __construct(PlasticResult $result, $limit, $page) { $this->result = $result; parent::__construct($result->hits(), $result->totalHits(), $limit, $page, ['path' => LengthAwarePaginator::resolveCurrentPath()]); $hitsReference =& $this->items; $result->setHits($hitsReference); }
/** * Fill the results hists into Model. * * @param Model $model * @param Result $result * * @return mixed|void */ public function fill(Model $model, Result $result) { $hits = $result->hits()->map(function ($hit) use($model) { return $this->fillModel($model, $hit); }); $result->setHits($hits); }