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

#[Explode]

Stage: VALIDATE (3)

Splits a string value into an array using a specified delimiter. The payload value is overwritten with the resulting array, making it ready for whereIn and similar queries.


Parameters

ParameterTypeRequiredDefaultDescription
$delimiterstring❌','The delimiter to split by

Usage

Default Delimiter (Comma)

use Kettasoft\Filterable\Engines\Foundation\Attributes\Annotations\Explode;

#[Explode]
protected function tags(Payload $payload)
{
    // "php,laravel,testing" → ["php", "laravel", "testing"]
    return $this->builder->whereIn('tag', $payload->value);
}

Custom Delimiter

#[Explode('|')]
protected function categories(Payload $payload)
{
    // "news|sports|tech" → ["news", "sports", "tech"]
    return $this->builder->whereIn('category', $payload->value);
}

Behavior

ScenarioResult
Value is a stringSplit into array, payload value is overwritten
Value is already an arrayReturned as-is

Combining with Other Attributes

#[Trim]
#[Explode(',')]
protected function statuses(Payload $payload)
{
    // "  active,pending,archived  " → ["active", "pending", "archived"]
    return $this->builder->whereIn('status', $payload->value);
}
Edit this page
Last Updated:
Contributors: kettasoft
Prev
MapValue
Next
Required