Parameters
Introduction
LaravelUi5 has three distinct ways to feed runtime values into your backend logic. They are not alternatives that compete — they are complementary, each with its own job, and all three are here to stay:
#[Parameter]binds a value from the route — a path segment in the URL, typically a resource identifier (…/{invoice}). This page.#[Setting]declares a configuration value — a named, typed, JSON-safe value with a default, attached to the class that consumes it. See Settings.#[Slot]resolves a value through a pipeline — a contextual value that can arrive from several places, with a guaranteed fallback (Request → Composition → Setting → Default). See Slots.
If you remember one thing: a Parameter answers which record, a Setting answers how is this configured, and a Slot answers in what context.
The three at a glance
#[Parameter] | #[Setting] | #[Slot] | |
|---|---|---|---|
| Comes from | the route (a URL path segment) | the declaration's own default | a resolution pipeline |
| Resolution order | positional, single source | default (Core) — storage-backed in the SDK | Request → Composition → Setting → Default; the SDK inserts Actor after Request |
| Declared on | the handler / provider class | the handler / provider or the artifact | the module class |
| Typical use | "which Invoice?" — resource identity | "how many rows? which endpoint?" — configuration | "which currency / date range / locale?" — context |
| Always present? | only if the route segment is supplied | yes — a default is mandatory | yes — a Slot always resolves (it has a declared default) |
| Reaches you as | a method argument | a virtual read-only property ($this->key) | a name → value map for the requested slots |
| Type vocabulary | ParameterType | ValueType | ParameterType (never Model) |
They never substitute for one another — which is exactly why all three remain a permanent part of the platform.
#[Parameter] — route-bound values
A Parameter pins a value taken straight from the request URL. It is the way an Action or Resource says "I operate on this specific record." Identifiers go in the path; everything else (payloads, options, flags) belongs in the request body and is validated with a Laravel FormRequest.
Declare it on the handler class and receive it as a method argument of the same name:
use LaravelUi5\Core\Ui5\Attributes\Parameter;
use LaravelUi5\Core\Parameters\Enums\ParameterType;
use LaravelUi5\Core\Ui5\AbstractConfigurable;
use LaravelUi5\Core\Ui5\Capabilities\ActionHandlerInterface;
#[Parameter(
name: 'invoice',
uriKey: 'invoice',
type: ParameterType::Model,
model: Invoice::class,
)]
class ApproveInvoiceHandler extends AbstractConfigurable implements ActionHandlerInterface
{
public function handle(Invoice $invoice, InvoiceApprover $approver): array // InvoiceApprover bound in a service provider
{
$approver->approve($invoice);
return ['status' => 'success', 'message' => "Invoice {$invoice->number} approved."];
}
}nameis the logical name; the resolved value is injected into the method argument that matches it (Invoice $invoiceabove).uriKeyis the path-segment name as the client sees it. The action's URL becomes…/[email protected]/{invoice}.type: ParameterType::Modelwith amodel:class resolves the segment to an Eloquent instance (model binding); scalar types cast the raw segment.- The attribute is repeatable — stack several to declare multiple path segments; their order defines the positional order in the URL.
Route Parameters are identifying input only. Keep payloads and options in the request body (a
FormRequest), per Laravel convention.
The type vocabulary
ParameterType is the scalar vocabulary shared with #[Slot]:
| Case | Resolves to |
|---|---|
String | the raw segment |
Integer | an int |
Float | a float |
Decimal | a fixed-precision numeric (distinct from Float's binary semantics) |
Boolean | a bool |
Date | a date |
DateTime | a date + time |
Model | an Eloquent instance — requires model: — Parameters only |
ParameterType::Model is the one case Slots may not use: a slot is a wire-shaped value, not a record reference. That is precisely the line between the two mechanisms.
Where it happens in the request
ExecutableInvoker — the path an Action, Resource, or Card takes — resolves Parameters first, injects Settings second, then builds the argument list from the method signature. Each argument is filled in this order:
- a
FormRequestsubclass → instantiated by the container, withauthorize()and validation triggered; - a name matching a declared Parameter → the resolved value, type-guarded against the method signature (a mismatch throws
InvalidParameterTypeException); - a class the container has a binding for (
$container->has()) → resolved as a service. An unbound class is not autowired here, even if the container could build it.
An argument that fits none of the three is a LogicException naming the class and method — the failure is loud and immediate, never a silent null.
Choosing between them
Ask one question about the value: is it an identifier in the URL, a knob somebody configures, or a context with a fallback?
- "Approve invoice 42" → the
42identifies a record →#[Parameter]. - "Show at most 20 rows" → a configured knob with a sensible default →
#[Setting]. - "Show the report for this quarter, in EUR" → contextual values resolved from several possible sources →
#[Slot].
They frequently appear together: an Action takes a route #[Parameter] for the record it acts on, a #[Setting] for its threshold, and a Report uses #[Slot]s for its date range and currency. Reach for the one that matches the kind of value — never force one to do another's job.
Related Links
- Settings — declared configuration values
- Slots — pipeline-resolved contextual values
- Ui5Action — the artifact type that most often declares Parameters
- Ui5Resource
- Execution Model