Blog

From draft order to approval in SeviaFlow

The warehouse has an order with three line items and a note saying the delivery window changed. Can someone start packing it? The items tell the team what to pack. A separate decision tells them when to start. In the Northstar example, the manager records that decision by choosing Confirm.

Follow one order through the handoff

In the Northstar walkthrough, Sofia opens a customer, creates an order and adds its items. Each item is a related record. The manager opens that same order, reviews the items and chooses Confirm. The workflow timeline records who acted and when. The manager can then open the confirmed-order queue and find the order there. The warehouse has a specific state to look for, and sales can answer who approved the handoff. Follow the Northstar scenario

Keep the approval rule on the transition

A Select field can store the word confirmed. A transition can also express which state must come first and who may make the decision. For a shop that requires a manager’s sign-off, add a confirm ability to the application’s OrderPolicy. In a resource workflow whose state field is status and whose states include draft and confirmed, add this entry to the transitions() list.

OrderResource.php
Transition::make('confirm')
    ->label('Confirm')
    ->from('draft')
    ->to('confirmed')
    ->authorize(
        static fn (Order $order, $user): bool =>
            $user?->can('confirm', $order) ?? false
    )

The application defines what qualifies someone to approve an order. When the transition runs, SeviaFlow also checks whether the actor may update that record. If your process requires an explanation for a different decision, such as cancellation, that transition can call requiresComment(). The comment is saved with the workflow activity. Define workflow states and transitions

Try the second click

On a test order, use an authorized manager account to confirm the draft. Reopen it and check the new state against the timeline entry. Confirm should no longer be available from this state. If a colleague left the page open before the first approval, their stale view should never be treated as evidence that a second approval succeeded.

When an integration needs the same handoff, enable flow() on the resource’s API contract. An authorized client can read GET /api/admin/resources/orders/42/flow for the current state and available transitions. It can submit POST /api/admin/resources/orders/42/flow/confirm while the transition is allowed. After a conflict, read the current state before deciding whether to retry. The panel and the integration can now agree on when packing may begin. Use the workflow endpoints