---
title: "Multi-stage pipelines — Requests for Laravel | Roundly"
description: "Route a request through sequential stages — each opens only once the previous one clears."
url: https://roundly-consulting.com/open-source/docs/requests-for-laravel/multi-stage-pipelines
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Requests for Laravel](https://roundly-consulting.com/open-source/docs/requests-for-laravel.md)

# Multi-stage pipelines

Define a sequential pipeline with stages(); each stage opens only once the previous one clears:

```php
use RoundlyConsulting\Approvals\DataTransferObjects\StageDefinition;
use RoundlyConsulting\Approvals\Enums\ApprovalRule;

$request = Requests::make()
    ->title('Payout')
    ->stages([
        new StageDefinition([$manager],  ApprovalRule::Unanimous, name: 'manager'),
        new StageDefinition([$finance],  ApprovalRule::Unanimous, name: 'finance'),
        new StageDefinition([$director], ApprovalRule::Unanimous, name: 'director'),
    ])
    ->create();

$request->currentStage()?->name; // 'manager'
```

Approvals move the request through the stages; the request flips to Approved when the last stage clears:

```php
Requests::approve($request, $manager);
$request->currentStage()?->name;   // 'finance'

Requests::approve($request, $finance);
$request->currentStage()?->name;   // 'director'

Requests::approve($request, $director);
$request->fresh()->status;         // Status::Approved
```

## StageDefinition

Each stage has its own approvers, rule, quorum and name:

```php
new StageDefinition(
    approvers: [$a, $b, $c],          // list<Model>
    rule: ApprovalRule::Quorum,       // defaults to ApprovalRule::Unanimous
    quorum: 2,                        // ?int — for quorum / weighted stages
    name: 'board',                    // ?string — shown by currentStage()->name
);
```

## Rejections inside a pipeline

By default a rejection in any stage rejects the whole request. Call rejectOnStageRejection(false) to skip the rejected stage and continue:

```php
$request = Requests::make()
    ->rejectOnStageRejection(false)
    ->stages([
        new StageDefinition([$manager], name: 'manager'),
        new StageDefinition([$finance], name: 'finance'),
    ])
    ->create();

// The first stage rejects, but the pipeline carries on to the next stage.
Requests::reject($request, $manager, reason: 'Skip me');

$request->fresh()->status;          // Status::New
$request->currentStage()?->name;    // 'finance'
```

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/requests-for-laravel.md)
