Skip to content

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

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.

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).

When a record enters a state:

  1. the open tasks of the previous state are closed,
  2. a decision task is created for the actors of the outgoing transitions (unless inbox(false)), see Decisions,
  3. the tasks of tasks([...]) are created,
  4. 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.

$workflow->stateColumn() shows the state as a badge: initial light, locked green, final dark, others blue. See Lists and detail page.