Documentation Index
Fetch the complete documentation index at: https://kawax.biz/llms.txt
Use this file to discover all available pages before exploring further.
What is the InteractsWithData trait?
Illuminate\Support\Traits\InteractsWithData is a trait that groups common APIs for array-like input data.
The trait itself requires only two abstract methods: all() and data().
Each class provides its own data retrieval logic.
In return, the trait gives you many high-frequency methods:
- Presence checks:
has(),hasAny(),exists(),missing() - Emptiness checks:
filled(),isNotFilled(),anyFilled() - Conditional execution:
whenHas(),whenFilled(),whenMissing() - Extraction:
only(),except() - Type conversion:
string(),boolean(),integer(),float(),date(),enum(),collect()
Relationship to Request methods
Illuminate\Http\Request from the request() helper uses InteractsWithData through Concerns\InteractsWithInput.
So everyday input access patterns are provided through this trait:
Request::get() is a Symfony-compatible method defined in the Request class itself.
In Laravel 13 source code, it is explicitly marked @deprecated use ->input() instead, so input() is the recommended method.
Main implementations in Laravel core
Classes that directly use InteractsWithData
| Class | Purpose |
|---|---|
Illuminate\Http\Concerns\InteractsWithInput | Input access API for Request |
Illuminate\Support\ValidatedInput | Wrapper for return values of validated() / safe() |
Illuminate\Support\Fluent | Fluent access to settings and arbitrary attributes |
Illuminate\Support\UriQueryString | Query string operations for Uri |
Illuminate\View\ComponentAttributeBag | Operations on Blade component attributes |
Related implementations with similar responsibilities
Illuminate\Session\Storeimplements similar APIs such ashas(),get(),only(), andexcept()independentlyIlluminate\Validation\Concerns\ValidatesAttributesprovides validation judgment logic and is intentionally separate from input access APIs
Relationship between the trait and core classes
Add it to your package classes
InteractsWithData fits package classes that store input arrays and should expose Laravel-style access APIs.
Practical use cases
- Option bags for external API clients
- Normalization layers for webhook payloads
- Configuration override resolver classes in packages
all() and data(), you avoid rebuilding input access APIs repeatedly and lower maintenance cost.