Laravel

Laravel Pipelines: Chain Operations Elegantly

January 16, 2026 1 min read 15 views

Chain operations with pipelines:

Basic Pipeline

$result = app(Pipeline::class)
    ->send($order)
    ->through([
        ValidateOrder::class,
        ApplyDiscount::class,
        CalculateTax::class,
        ProcessPayment::class,
    ])
    ->thenReturn();

Pipe Class

class ApplyDiscount
{
    public function handle($order, Closure $next)
    {
        $order->applyDiscount();
        return $next($order);
    }
}

Custom Method

->via('process')
->through([...]);
Share this post:

Related Posts

Comments (0)

Please log in to leave a comment. Log in

No comments yet. Be the first to comment!