#[SkipIf]
Stage: CONTROL (1) — Repeatable
Skips the filter execution if a specified condition on the Payload is met. Uses the Payload's is* methods for checks.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
$check | string | ✅ | — | The Payload is* check name (e.g., 'empty', 'null', '!numeric') |
$message | string | ❌ | '' | Custom message when the filter is skipped |
Usage
use Kettasoft\Filterable\Engines\Foundation\Attributes\Annotations\SkipIf;
#[SkipIf('empty')]
protected function status(Payload $payload)
{
return $this->builder->where('status', $payload->value);
}
Negation with !
Prefix the check name with ! to negate it:
// Skip if value is NOT numeric
#[SkipIf('!numeric')]
protected function price(Payload $payload)
{
return $this->builder->where('price', $payload->value);
}
Available Checks
Any is* method on the Payload class can be used:
| Check | Maps To | Description |
|---|---|---|
'empty' | $payload->isEmpty() | Value is empty |
'null' | $payload->isNull() | Value is null |
'emptyString' | $payload->isEmptyString() | Value is a blank string |
'numeric' | $payload->isNumeric() | Value is numeric |
'boolean' | $payload->isBoolean() | Value is boolean-like |
'string' | $payload->isString() | Value is a string |
'array' | $payload->isArray() | Value is an array |
'date' | $payload->isDate() | Value is a valid date |
'json' | $payload->isJson() | Value is valid JSON |
'!numeric' | !$payload->isNumeric() | Value is not numeric |
'!empty' | !$payload->isEmpty() | Value is not empty |
Stacking Multiple Checks
Since #[SkipIf] is repeatable, you can stack multiple conditions:
#[SkipIf('empty')]
#[SkipIf('emptyString')]
protected function title(Payload $payload)
{
return $this->builder->where('title', 'like', $payload->asLike());
}
Each #[SkipIf] is evaluated independently. If any of them triggers, the filter is skipped.
Behavior
| Scenario | Result |
|---|---|
Check returns true | Filter is skipped |
Check returns false | Filter executes normally |
Negated check (!) true | Filter is skipped |
| Method doesn't exist | InvalidArgumentException is thrown |
