Skip to content
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

Building a Filter Query for ModerationStatus::APPROVED #55

Open
dev-ns8 opened this issue Jul 9, 2021 · 0 comments
Open

Building a Filter Query for ModerationStatus::APPROVED #55

dev-ns8 opened this issue Jul 9, 2021 · 0 comments

Comments

@dev-ns8
Copy link

dev-ns8 commented Jul 9, 2021

Hello I am maintaining a project that uses this library for moderation, and on some of our content we like to filter by 'Approved', 'Pending' , 'Rejected', and 'Postponed'.

We have a custom Status Filter that extends Laravel\Nova\Filters\Filter. In this class, we define an apply method as such:

    public function apply(Request $request, $query, $value)
    {
        switch($value) {
            case $this->all:
            default:
                $query = $query->withAnyStatus();
                break;
            case ModerationStatus::PENDING:
                $query = $query->pending();
                break;
            case ModerationStatus::APPROVED:
                break;
            case ModerationStatus::REJECTED:
                $query = $query->rejected();
                break;
            case ModerationStatus::POSTPONED:
                $query = $query->postponed();
                break;
        }

        return $query;
    }

Now I am sorry if this is the wrong place to be asking this, but as it pertains to Laravel and Nova, how can I add an approved() filter to the $query() that is being returned? I see this query is of type \Illuminate\Database\Eloquent\Builder and I kind of half expected to see this library extend that somewhere in the code. This however is not the case and digging through the API reference for \Illuminate\Database\Eloquent\Builder I don't see any reference to these methods being performed on the $query in the above function.

Could someone maybe point me in the right direction of where to look? Is hootlex not fully compatible with Laravel and Nova and therefore doesn't offer a way to filter by ModerationStatus::APPROVED ?

Any help would be greatly appreciated

@dev-ns8 dev-ns8 changed the title Building a Filter Query for ModerationStatus::Approved Building a Filter Query for ModerationStatus::APPROVED Jul 9, 2021
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