States
State::make('draft')->label('Draft')->initial(),State::make('submitted')->label('Submitted'),State::make('approved')->label('Approved')->locked(),State::make('ordered')->label('Ordered')->locked()->final(),State::make('in_review')->label('In review')->tasks([...]),Names: lower case letters, digits and _, up to 40 characters; they are
stored in the state column and in the history, so keep them stable.
| Method | Meaning |
|---|---|
label() |
text in lists, buttons and history; may be a language key |
initial() |
new records start here; exactly one state |
locked() |
the record cannot be edited or deleted (panel, API, attachments); only transitions change it |
final() |
the workflow ends here; no outgoing transitions |
inbox(false) |
the actors of the outgoing transitions get no decision task; default: on, except for the initial and final states |
tasks([...]) |
tasks created when a record enters the state, see Tasks in parallel |
duration(5) |
working days the state may take, see Durations and deadline |
whenOverdue(Escalation) |
what happens when the state takes longer; default: remind its actors |
pausesClock() |
the clock of the case stops in this state |
goal() |
the final state that counts as the regular end |
Locked states
Section titled “Locked states”While a record is in a locked state, canUpdate() and canDelete() of
the resource return false: no edit page, no delete, no attachment
changes, no API update. Actions of the resource still run; check the
state in their visible() where needed. Transitions are the only way out.
Typical: an approved order must not change any more; to change it, a transition back (e.g. reopen) is needed – visible in the history.
Final states
Section titled “Final states”Records in a final state are finished: there are no transitions out of it, and no decision task is created. A workflow can have several final states (ordered, cancelled).
Entering a state
Section titled “Entering a state”When a record enters a state:
- the open tasks of the previous state are closed,
- a decision task is created for the actors of the outgoing transitions
(unless
inbox(false)), see Decisions, - the tasks of
tasks([...])are created, - its due date, the forecast and the risk of the case are calculated; the clock of the case starts when it leaves the initial state.
In the list
Section titled “In the list”$workflow->stateColumn() shows the state as a badge: initial light,
locked green, final dark, others blue. See
Lists and detail page.