The array
field type is used for storing indexed arrays. Items can be simple or complex types. By default, any item type is valid.
// streams/example.json
"fields": {
"items": {
"type": "array"
}
}
{
"items": [
"John Doe",
"Jane Smith"
]
}
Basic array
access:
@verbatim// Array access
{{ $entry->items[0] }}
@foreach ($entry->items as $index => $value)
{{ $index }}: {{ $value }}
@endforeach
@endverbatim
The decorated value provides collection access to the data.
@verbatim// Decorated value
{{ $entry->decorate('items')->implode(', ') }}
@endverbatim
The array can optionally be wrapped with a generic collection or arrayable classname automatically when accessing the field.
{
// streams/example.json
"fields": {
"items": {
"type": "array",
"config": {
"wrapper": "array|collection|App\\MyCollection"
}
}
}
// welcome.blade.php
@verbatim@if($entry->items->isNotEmpty())
@foreach ($entry->items as $item)
//
@endforeach
@endif
@endverbatim
Use the items
configuration to specify the allowed item types using field configurations. If specified, each item must be valid against any of the provided types.
// streams/example.json
"fields": {
"items": {
"type": "array",
"config": {
"wrapper": "array|collection|App\\MyCollection",
"items": [
{ "type": "integer" },
{ "type": "string" },
{
"type": "object",
"config": {
"schemas": [
{ "stream": "addresses" }
]
}
},
]
}
}
}
A blank TALL-stack Laravel project with Streams.
The fundamental features and utilities offered by the Streams platform.
A universal and extensible RESTful API for Streams.
Extensible, user-friendly, and performant control panel, components, and services.
Dev tooling for Laravel Streams.