Currently I am working on a donation collection application. In this I have to create customs filters to filter out the recipients from different categories.

So, to create the filter, I have to run the following command.

php artisan nova:filter RecipientStatus

When you run the command, RecipientStatus.php file will be created in the folder app/Nova/Filters/

In my application, I am trying to filter the recipients by approval status. I have a boolean field in my recipients table named approved_by, so in the file created in the previous step, I add the following code.

...

public function apply(Request $request, $query, $value)
{
    if ($value == 1)
        return $query->whereNotNull('approved_by');
    else 
        return $query->whereNull('approved_by');
}

public function options(Request $request)
{
    return [
        'Approved' => 1,
        'Not Approved' => 0,
    ];
}

Now I have to register the filter. Open the Recipient.php in app/Nova/ directory and add the following code.

...

public function filters(Request $request)
{
    return [
        new Filters\RecipientStatus,
    ];
}

...

Go to nova dashboard. Select Recipient resource from sidebar, now you can see the filter.