Warp

A purchase approval flow in Filament: route by amount, send back, approve

5 min read

Liam in sales wants six standing desks for his team, 1,500,000 in total. Company rules say that his manager approves every purchase, the department director also approves anything over a million, finance gives an opinion, and purchasing is told. Today this happens by email: Liam writes to his manager, the manager forwards it to the director, someone forgets to copy finance, and three weeks later nobody knows where the request is.

A status column and a "Approve" button on the record cannot carry this. Who approves depends on the amount and on who Liam's manager is today. A manager may send it back with a question. And when the request comes back, the approvers want to know what changed.

This article follows one purchase request through the Warp Flow demo: the route worked out from the amount and the org chart, a return with a reason, a resubmission and an approval. All pictures are from the live demo. The demo uses yen, hence the large numbers.

The scene: a purchase request

Liam fills in an ordinary Filament form: the item, the category, the vendor, the quantity and the unit price.

A purchase request form with Item Standing desks, Category Furniture, Vendor Okamura, Quantity 6 and Unit price 250,000
Six standing desks at 250,000 each. A normal Filament resource.

Step 1: make the model approvable

Register the plugin with the models that can be approved:

use Qalainau\FilamentWarpFlow\FilamentWarpFlowPlugin;

->plugin(
    FilamentWarpFlowPlugin::make()
        ->models([PurchaseRequest::class])
        ->canManage(fn (User $user) => $user->is_admin),
)

The model implements Approvable, uses HasApprovals, and declares the fields a flow may branch on:

use Qalainau\FilamentWarpFlow\ConditionField;
use Qalainau\FilamentWarpFlow\Concerns\HasApprovals;
use Qalainau\FilamentWarpFlow\Contracts\Approvable;

class PurchaseRequest extends Model implements Approvable
{
    use HasApprovals;

    public static function approvalConditionFields(): array
    {
        return [
            ConditionField::number('amount', 'Amount'),
            ConditionField::select('category', 'Category', PurchaseCategory::class),
        ];
    }
}

And the edit page gets the approval actions. Each one only shows when the current user can use it right now:

use Qalainau\FilamentWarpFlow\Actions\ApprovalActions;

protected function getHeaderActions(): array
{
    return [...ApprovalActions::make(), DeleteAction::make()];
}

The route itself is not code. An admin builds it in the panel's flow editor and presses Publish. The demo's purchase flow is: the applicant's manager, then a branch on the amount (over 5,000,000: director and president; over 1,000,000: director), an IT check for software, a finance review as a consultation, and purchasing for information.

Approvers are found relative to the applicant: their manager, the head of their department. When someone changes teams, the flow does not need to change.

Step 2: see the route before sending

"Submit for approval" shows exactly who will get the request, in which order, before anything is sent. 1,500,000 is over a million, so the department director is on it.

The Submit for approval dialog listing the route: 1 Manager (Approval) Alex Morgan, 2 Department director (Approval) Emma Wilson, 3 Finance review (Consultation) Takeshi Mori, 4 Purchasing (For information) Hannah Weber, and a comment field
Four steps, each with its type and person. Under a million, step 2 would not be there.

The route is fixed when the request is sent. Publishing a new version of the flow later does not change requests already under way.

A request is made from the record as saved. If the form has unsaved changes, the dialog asks to save first, so nobody approves numbers that are not in the database.

Step 3: the manager sends it back

Alex, Liam's manager, finds the request in the approval inbox. The request page shows the summary, the route and a row of approval stamps. The dashed blue circle is whose turn it is.

The request page seen by the manager: Approve, Return and Reject buttons, a summary with status In review and Now Manager — Alex Morgan, the route on the right and a row of stamps with Alex's turn marked
Alex's turn. Approve, return or reject.

Alex wants a second quote before saying yes, so they press "Return". The request can go back to Liam or to an earlier approval step. A reason is required, and it stays in the request's thread.

The Return dialog with Return to set to the applicant Liam Brown and a required Reason field
Back to the applicant, with a reason.

Liam sees the request as Returned, with an orange "Returned" stamp in Alex's box, and buttons to resubmit or withdraw it.

The request seen by the applicant: status Returned, an orange Returned stamp in the manager's box, and Resubmit and Withdraw buttons
The ball is in Liam's court. The stamps show who did what.

Step 4: resubmit and approve

Liam resubmits with a comment. By default the request picks up at the step that returned it, so Alex sees it again without the request starting over. If the change alters the route before that step (a higher amount that adds a director), it starts from the first step.

Alex approves.

Approve, comment, confirm. The route moves on to the director.
After the approval: step 1 Manager is checked as Approved, step 2 Department director Emma Wilson is Waiting, Alex's stamp is a red Approved stamp, and the summary says Nothing changed since the last submission
Alex's red stamp, Emma's turn now. The summary also says nothing changed since the last submission.

That last line matters. When a returned request comes back with changes, the request page shows them with the old value struck through ("480,000 → 398,000"), and the approval email says "Changed: Amount 480,000 → 398,000". Approvers do not have to compare by memory.

Other scenes

  • Expense claims: travel over a set amount also goes to the director.
  • Proposals and contracts: branch on the kind of contract or the department of the applicant.
  • Leave requests: approved by themselves when the manager does not answer in time (due times and escalation).
  • Requests with no model at all: a business trip request built from a request form in the panel, with no code.

The four step types cover most company rules: Approval (approve, return or reject), Consultation (agree or disagree; a disagreement does not stop the request), For information (people mark it as read) and Post-review (after the final approval).

Limits worth knowing

  • Conditions can only use the fields the model declares in approvalConditionFields() and the applicant's department and position. No free-form expressions.
  • Unsaved edits are not part of a request.
  • After a rejection or a withdrawal, the record is submitted again as a new request.
  • In the demo, everyone sees "Reassign" so you can try it. In your app, only people allowed to manage flows reassign steps.

Try it

Open the purchase requests in the demo. Use "Acting as" in the top bar to become the applicant, create a request over 1,000,000 and press "Submit for approval". Then switch to the manager and return or approve it from the approval inbox. No sign-up, and the data is reset every hour.

More from the blog

See who is free next week and book them, in Filament

An agency manager needs 40 hours for a project that starts Monday. The planner shows only the people who have the time, the booking is a drag, and the overbooked project manager gets a fix in two clicks.

Laravel Rust vs Laravel Go vs Laravel PHP: The Complete Real-World Benchmark Guide

We benchmarked Laravel Rust, Laravel Go v0.1.0, and Laravel PHP (FPM, FrankenPHP, Swoole, Workerman) across 8 real workloads on the exact same machine — from 1,000-user spikes and heavy ORM to 100k-row deep pagination. Continuously updated as new tests land.

Work through support tickets without leaving the list, in Filament

A support agent opens a ticket, assigns it, sets it to pending and moves on to the next one with the arrow key. The list stays on the left; the View and Edit pages you already have open on the right.

Filament + AI coding tips, by email

How to fit Warp plugins into your own app and pair them with Claude Code or Cursor: prompts that work, mistakes AI makes, real examples. Once or twice a month. Unsubscribe anytime.

Ask us anything about Warp

No email address or sign-up needed.

We read every question and answer here on the site, usually within a day. Others see your question after we have checked it.

What's stopping you from using Warp's plugins?

One question. We read every answer, and it decides what we build next. It is not shown on the site.

What's stopping you from using Warp's plugins?