scout-elasticsearch-driver icon indicating copy to clipboard operation
scout-elasticsearch-driver copied to clipboard

Add getModel to Builder

Open porozhnyy opened this issue 6 years ago • 3 comments
trafficstars

Fix not exists getModel method in Builder

porozhnyy avatar Dec 15 '18 16:12 porozhnyy

Why do you need it in Builder? What's the use case?

babenkoivan avatar Jun 23 '19 12:06 babenkoivan

@babenkoivan I use 2 types of filters in my application - ES and Postgresql. Depending on whether there is a search method in the model or not, I further define the search logic. So far I have to use this code, which is not very beautiful:

private function getModel($builder)
{
    if (!($builder instanceof Illuminate\Database\Eloquent\Builder)) {
        return $builder->model;
    }

    return $builder->getModel();
}
if (method_exists($this->getModel($builder), 'search')) {
    //my code
}

porozhnyy avatar Jun 23 '19 16:06 porozhnyy

This is a typo of the century)))

porozhnyy avatar Jun 01 '20 19:06 porozhnyy