Skip to content
This repository has been archived by the owner on Nov 4, 2021. It is now read-only.

Add getModel to Builder #166

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add getModel to Builder #166

wants to merge 2 commits into from

Conversation

porozhnyy
Copy link

Fix not exists getModel method in Builder

Fix not exists getModel method in Builder
berkansahin
berkansahin previously approved these changes Apr 5, 2019
@babenkoivan
Copy link
Owner

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

@porozhnyy
Copy link
Author

porozhnyy commented Jun 23, 2019

@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
}

@iget-esoares iget-esoares reopened this Jun 1, 2020
Copy link
Collaborator

@iget-esoares iget-esoares left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return was wrongly typed retutn.

@porozhnyy
Copy link
Author

porozhnyy commented Jun 1, 2020

This is a typo of the century)))

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants