Skip to content

Building a Filter Query for ModerationStatus::APPROVED #55

@dev-ns8

Description

@dev-ns8

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions