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"
}
]
}
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.
{
"type": "relationship",
"config": {
"related": "stream"
}
}
{
"type": "multiple",
"config": {
"related": "stream"
}
}
{
"type": "file",
"config": {
"path": "storage::uploads"
}
}
{
"type": "image",
"config": {
"path": "storage::uploads.img"
}
}
The fundamental features and utilities offered by the Streams platform.
A full featured, universal, and extensible RESTful API.
Extensible, user-friendly, and performant control panel and user interface utilities and services.
CLI Tooling for Laravel Streams.