FilterableFilterable
Home
📦 Installation
  • Setting Up Filterable
  • Discover Command
  • Listing All Filters
  • Testing Filters
  • Inspecting Filterable Classes
  • Caching
GitHub
Home
📦 Installation
  • Setting Up Filterable
  • Discover Command
  • Listing All Filters
  • Testing Filters
  • Inspecting Filterable Classes
  • Caching
GitHub
  • Home
  • Introduction
  • Installation
  • Service Provider
  • How It Works
  • Engines

    • Invokable

      • Overview
      • Annotations

        • Overview
        • Authorize
        • SkipIf
        • Trim
        • Sanitize
        • Cast
        • DefaultValue
        • MapValue
        • Explode
        • Required
        • In
        • Between
        • Regex
        • Scope
    • Tree
    • Ruleset
    • Expression
  • Features

    • Lifecycle Hooks
    • Header-Driven Filter Mode
    • Auto Register Filterable Macro
    • Conditional Logic
    • Filter Aliases
    • Through callbacks
    • Auto Binding
    • Custom engines
    • Data Provisioning
  • Execution

    • Invoker
  • API Reference

    • Filterable
    • Filterable facade
    • Payload
    • Sorter
  • Caching

    • Overview
    • Getting Started
    • Strategies
    • Auto Invalidation
    • Cache Profiles
    • Scoping Cache
    • Monitoring Cached Items
    • API Reference
    • Examples
  • CLI

    • Setup Filterable
    • Discover Filters
    • Test Filter
    • List Filters
    • Inspect Filter
  • Exceptions
  • Event System
  • Profile Management
  • Profiler
  • Sorting
  • Authorization
  • Validation
  • Sanitization

#[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

ParameterTypeRequiredDefaultDescription
$checkstring✅—The Payload is* check name (e.g., 'empty', 'null', '!numeric')
$messagestring❌''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:

CheckMaps ToDescription
'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

ScenarioResult
Check returns trueFilter is skipped
Check returns falseFilter executes normally
Negated check (!) trueFilter is skipped
Method doesn't existInvalidArgumentException is thrown
Edit this page
Last Updated:
Contributors: kettasoft
Prev
Authorize
Next
Trim