Skip to content

Multiple filter values #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Dec 6, 2016 · 4 comments
Closed

Multiple filter values #34

ghost opened this issue Dec 6, 2016 · 4 comments

Comments

@ghost
Copy link

ghost commented Dec 6, 2016

I'm trying to filter my query through multiple filter values like so:

api/v1/questions?filter[questionType]=questionType1,questionType2

But apparently this is not supported out of the box. Any guidance on how to achieve this would be appreciated.

@ghost
Copy link
Author

ghost commented Dec 6, 2016

Solved it by using this in my Search class:

/**
     * @param Builder $builder
     * @param Collection $filters
     */
    protected function filter(Builder $builder, Collection $filters)
    {
        if ($filters->has('questionType')) {
            $questionTypes = explode(",", $filters->get('questionType'));

            $builder->whereIn('questions.question_type', $questionTypes);
        }
    }

    /**
     * @param Collection $filters
     * @return bool
     */
    protected function isSearchOne(Collection $filters)
    {
        return false;
    }

@ghost ghost closed this as completed Dec 6, 2016
@ghost
Copy link
Author

ghost commented Dec 6, 2016

Hope these issues help you somehow to build the wiki better.

@lindyhopchris
Copy link
Member

Yes, I do understand that there needs to be a proper wiki... it's just fitting it in around work deadlines is proving problematic at the moment. I do promise to get to it.

@ghost
Copy link
Author

ghost commented Dec 6, 2016

Yeah I do understand that, and by no means I'm trying to put pressure on you. Take your time. I'm just trying to kind of figure it out on my own and if I find a really hard one to figure out then I'll post an issue and eventually a solution, as I also think this might help you remember important parts for the wiki. :)

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant