Fields represent the type and characteristics of your stream data. For example a "name" field would likely be a string field type.
Fields are strictly concerned with data. Please see the UI package for configuring field inputs.
Fields can be defined within the JSON configuration for your streams. You can get started by simply defining fields by handle
and their type
respectively.
// streams/contacts.json
{
"fields": [
{
"handle": "title",
"type": "string"
}
]
}
To define more information about the field use an array:
// streams/contacts.json
{
"fields": [
{
"handle": "title",
"name": "Title",
"description": "The title of the film.",
"type": "string",
"rules": ["min:4"],
"config": {
"default": "Untitled"
},
"example": "Star Wars: The Force Awakens",
"protected": false
}
]
}
Define Laravel validation rules for fields and they will be merged the stream validation rules.
// streams/contacts.json
{
"fields": [
{
"handle": "name",
"type": "string",
"rules": ["required", "max:100"]
},
{
"handle": "email",
"type": "email",
"rules": ["required", "email:rfc,dns"]
},
{
"handle": "company",
"type": "string",
"rules": ["required", "unique"]
}
]
}
Values are stored as an image source
Image::make($entry->profile_image)->url();
Field decorators provide expanded function to entry attributes like a universal presenter.
The below example demonstrates the image
field decorator:
$entry->decorate('profile_image')->url();
You may also use magic methods derived from "camel casing" the field's handle to invoke decoration.
$entry->profileImage()->url();
The field type is responsible for validating, casting, and more for its specific data type.
@foreach (Streams::entries('docs_core')->where('category', 'field_types')->orderBy('sort', 'ASC')->orderBy('name', 'ASC')->get() as $entry)
{
"type": "relationship",
"config": {
"related": "stream"
}
}
{
"type": "multiple",
"config": {
"related": "stream"
}
}
{
"type": "file",
"config": {
"path": "storage::uploads"
}
}
{
"type": "image",
"config": {
"path": "storage::uploads.img"
}
}
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.