Sleimanx2\Plastic\DSL\SearchBuilder::model PHP Method

model() public method

Set the eloquent model to use when querying elastic search.
public model ( Model $model )
$model Illuminate\Database\Eloquent\Model
    public function model(Model $model)
    {
        // Check if the model is searchable before setting the query builder model
        $traits = class_uses($model);
        if (!isset($traits[Searchable::class])) {
            throw new InvalidArgumentException(get_class($model) . ' does not use the searchable trait');
        }
        $this->type($model->getDocumentType());
        if ($index = $model->getDocumentIndex()) {
            $this->index($index);
        }
        $this->model = $model;
        return $this;
    }