Skip to content

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 fromthe route (a URL path segment)the declaration's own defaulta resolution pipeline
Resolution orderpositional, single sourcedefault (Core) — storage-backed in the SDKRequest → Composition → Setting → Default; the SDK inserts Actor after Request
Declared onthe handler / provider classthe handler / provider or the artifactthe 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 suppliedyes — a default is mandatoryyes — a Slot always resolves (it has a declared default)
Reaches you asa method argumenta virtual read-only property ($this->key)a name → value map for the requested slots
Type vocabularyParameterTypeValueTypeParameterType (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:

php
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."];
    }
}
  • name is the logical name; the resolved value is injected into the method argument that matches it (Invoice $invoice above).
  • uriKey is the path-segment name as the client sees it. The action's URL becomes …/[email protected]/{invoice}.
  • type: ParameterType::Model with a model: 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]:

CaseResolves to
Stringthe raw segment
Integeran int
Floata float
Decimala fixed-precision numeric (distinct from Float's binary semantics)
Booleana bool
Datea date
DateTimea date + time
Modelan 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:

  1. a FormRequest subclass → instantiated by the container, with authorize() and validation triggered;
  2. a name matching a declared Parameter → the resolved value, type-guarded against the method signature (a mismatch throws InvalidParameterTypeException);
  3. 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 42 identifies 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.