To define a new filter, extend the Waterhole\Filters\Filter class:
namespace App\Filters;
use Illuminate\Database\Eloquent\Builder;
use Waterhole\Filters\Filter;
class Unanswered extends Filter
{
/**
* The text label for the filter.
*/
public function label(): string
{
return 'Unanswered';
}
/**
* Apply the filter to the feed query builder.
*/
public function apply(Builder $query): void
{
$query->where('is_answered', false);
}
}
Post filters need to be registered in order to make them available for selection when configuring a channel. To register a post filter, call the add method on the PostFilters extenders:
use App\Filters;
use Waterhole\Extend;
Extend\PostFilters::add(Filters\Unanswered::class);