sed -n '1,220p' app/Services/InventoryService.php

<?php

namespace App\Services;

use App\Enums\InventoryPolicy;
use App\Exceptions\InsufficientInventoryException;
use App\Models\InventoryItem;
use Illuminate\Support\Facades\DB;
use InvalidArgumentException;

class InventoryService
{
    public function checkAvailability(InventoryItem $item, int $quantity): bool
    {
        $this->assertPositiveQuantity($quantity);

        if ($item->policy === InventoryPolicy::Continue) {
            return true;
        }

        return $this->available($item) >= $quantity;
    }

    public function reserve(InventoryItem $item, int $quantity): void
    {
        $this->assertPositiveQuantity($quantity);

        DB::transaction(function () use ($item, $quantity): void {
            $locked = $this->freshItem($item);

            if (! $this->checkAvailability($locked, $quantity)) {
                throw InsufficientInventoryException::forQuantity($this->available($locked), $quantity);
            }

            $locked->forceFill([
                'quantity_reserved' => $locked->quantity_reserved + $quantity,
            ])->save();
        });
    }

    public function release(InventoryItem $item, int $quantity): void
    {
        $this->assertPositiveQuantity($quantity);

        DB::transaction(function () use ($item, $quantity): void {
            $locked = $this->freshItem($item);

            if ($locked->quantity_reserved < $quantity) {
                throw new InvalidArgumentException('Cannot release more inventory than is reserved.');
            }

            $locked->forceFill([
                'quantity_reserved' => $locked->quantity_reserved - $quantity,
            ])->save();
        });
    }

    public function commit(InventoryItem $item, int $quantity): void
    {
        $this->assertPositiveQuantity($quantity);

        DB::transaction(function () use ($item, $quantity): void {
            $locked = $this->freshItem($item);

            if ($locked->quantity_reserved < $quantity) {
                throw new InvalidArgumentException('Cannot commit more inventory than is reserved.');
            }

            $locked->forceFill([
                'quantity_on_hand' => $locked->quantity_on_hand - $quantity,
                'quantity_reserved' => $locked->quantity_reserved - $quantity,
            ])->save();
        });
    }

    public function restock(InventoryItem $item, int $quantity): void
    {
        $this->assertPositiveQuantity($quantity);

        DB::transaction(function () use ($item, $quantity): void {
            $locked = $this->freshItem($item);

            $locked->forceFill([
                'quantity_on_hand' => $locked->quantity_on_hand + $quantity,
            ])->save();
        });
    }

    private function available(InventoryItem $item): int
    {
        return $item->quantity_on_hand - $item->quantity_reserved;
    }

    private function freshItem(InventoryItem $item): InventoryItem
    {
        return InventoryItem::withoutGlobalScopes()
            ->whereKey($item->getKey())
            ->lockForUpdate()
            ->firstOrFail();
    }

    private function assertPositiveQuantity(int $quantity): void
    {
        if ($quantity <= 0) {
            throw new InvalidArgumentException('Inventory quantity must be greater than zero.');
        }
    }
}


Output:
Chunk ID: 58014c
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 828
Output:
<?php

namespace App\Services;

use App\Enums\InventoryPolicy;
use App\Exceptions\InsufficientInventoryException;
use App\Models\InventoryItem;
use Illuminate\Support\Facades\DB;
use InvalidArgumentException;

class InventoryService
{
    public function checkAvailability(InventoryItem $item, int $quantity): bool
    {
        $this->assertPositiveQuantity($quantity);

        if ($item->policy === InventoryPolicy::Continue) {
            return true;
        }

        return $this->available($item) >= $quantity;
    }

    public function reserve(InventoryItem $item, int $quantity): void
    {
        $this->assertPositiveQuantity($quantity);

        DB::transaction(function () use ($item, $quantity): void {
            $locked = $this->freshItem($item);

            if (! $this->checkAvailability($locked, $quantity)) {
                throw InsufficientInventoryException::forQuantity($this->available($locked), $quantity);
            }

            $locked->forceFill([
                'quantity_reserved' => $locked->quantity_reserved + $quantity,
            ])->save();
        });
    }

    public function release(InventoryItem $item, int $quantity): void
    {
        $this->assertPositiveQuantity($quantity);

        DB::transaction(function () use ($item, $quantity): void {
            $locked = $this->freshItem($item);

            if ($locked->quantity_reserved < $quantity) {
                throw new InvalidArgumentException('Cannot release more inventory than is reserved.');
            }

            $locked->forceFill([
                'quantity_reserved' => $locked->quantity_reserved - $quantity,
            ])->save();
        });
    }

    public function commit(InventoryItem $item, int $quantity): void
    {
        $this->assertPositiveQuantity($quantity);

        DB::transaction(function () use ($item, $quantity): void {
            $locked = $this->freshItem($item);

            if ($locked->quantity_reserved < $quantity) {
                throw new InvalidArgumentException('Cannot commit more inventory than is reserved.');
            }

            $locked->forceFill([
                'quantity_on_hand' => $locked->quantity_on_hand - $quantity,
                'quantity_reserved' => $locked->quantity_reserved - $quantity,
            ])->save();
        });
    }

    public function restock(InventoryItem $item, int $quantity): void
    {
        $this->assertPositiveQuantity($quantity);

        DB::transaction(function () use ($item, $quantity): void {
            $locked = $this->freshItem($item);

            $locked->forceFill([
                'quantity_on_hand' => $locked->quantity_on_hand + $quantity,
            ])->save();
        });
    }

    private function available(InventoryItem $item): int
    {
        return $item->quantity_on_hand - $item->quantity_reserved;
    }

    private function freshItem(InventoryItem $item): InventoryItem
    {
        return InventoryItem::withoutGlobalScopes()
            ->whereKey($item->getKey())
            ->lockForUpdate()
            ->firstOrFail();
    }

    private function assertPositiveQuantity(int $quantity): void
    {
        if ($quantity <= 0) {
            throw new InvalidArgumentException('Inventory quantity must be greater than zero.');
        }
    }
}


rg -n "title_snapshot|sku_snapshot|discount_allocations_json|tax_lines_json" resources/views/livewire/admin/orders resources/views/livewire/storefront/account/orders resources/views/livewire/storefront/checkout -S


sed -n '1,280p' resources/views/livewire/admin/orders/show.blade.php


sed -n '1,220p' resources/views/livewire/storefront/account/orders/show.blade.php


sed -n '1,280p' resources/views/livewire/admin/orders/show.blade.php

            <flux:button :href="route('admin.orders.index')" wire:navigate variant="ghost" icon="arrow-left">
                Orders
            </flux:button>

                <flux:heading size="xl">{{ $order->order_number }}</flux:heading>
                <flux:text class="mt-1">{{ $order->email }} · {{ $order->placed_at?->format('M j, Y H:i') }}</flux:text>

            @if ($order->payment_method === \App\Enums\PaymentMethod::BankTransfer && $order->financial_status === \App\Enums\FinancialStatus::Pending)
                <flux:button wire:click="confirmBankTransferPayment" variant="primary" icon="banknotes" data-test="confirm-payment-button">
                    Confirm payment
                </flux:button>
            @endif

            @if (in_array($order->financial_status, [\App\Enums\FinancialStatus::Paid, \App\Enums\FinancialStatus::PartiallyRefunded], true) && $refundableAmount > 0)
                <flux:modal.trigger name="refund-order">
                    <flux:button variant="danger" icon="receipt-refund" data-test="refund-modal-button">
                        Refund
                    </flux:button>
                </flux:modal.trigger>
            @endif

            @if (in_array($order->financial_status, [\App\Enums\FinancialStatus::Paid, \App\Enums\FinancialStatus::PartiallyRefunded], true) && collect($remainingFulfillmentQuantities)->sum() > 0)
                <flux:modal.trigger name="fulfillment-order">
                    <flux:button variant="filled" icon="truck" data-test="fulfillment-modal-button">
                        Create fulfillment
                    </flux:button>
                </flux:modal.trigger>
            @endif

    @if ($actionMessage !== '')
        <flux:callout color="green" icon="check-circle" data-test="order-action-message">{{ $actionMessage }}</flux:callout>
    @endif

    @error('orderAction')

            {{ $message }}

    @enderror

    @error('fulfillment')

            {{ $message }}

    @enderror

    @if (! in_array($order->financial_status, [\App\Enums\FinancialStatus::Paid, \App\Enums\FinancialStatus::PartiallyRefunded], true) && collect($remainingFulfillmentQuantities)->sum() > 0)
        <flux:callout color="amber" icon="exclamation-triangle" data-test="fulfillment-guard-message">
            Cannot create fulfillment. Payment must be confirmed before items can be fulfilled. Current financial status: {{ Str::headline($order->financial_status->value) }}.
        </flux:callout>
    @endif

Order

                <flux:badge>{{ Str::headline($order->status->value) }}</flux:badge>

Payment

                <flux:badge :color="$order->financial_status->value === 'paid' ? 'green' : ($order->financial_status->value === 'pending' ? 'amber' : 'zinc')">
                    {{ Str::headline($order->financial_status->value) }}
                </flux:badge>

Fulfillment

                <flux:badge :color="$order->fulfillment_status->value === 'fulfilled' ? 'green' : ($order->fulfillment_status->value === 'partial' ? 'amber' : 'zinc')">
                    {{ Str::headline($order->fulfillment_status->value) }}
                </flux:badge>

Total

                {{ \App\Support\Money::format($order->total_amount, $order->currency) }}

            lines as $line)

getKey() }}">
                                        {{ $line->orderLine?->title_snapshot }} · Qty {{ $line->quantity }}

                                @endforeach

                    @empty

No fulfillments yet.

                    @endforelse

                <flux:heading size="lg">Customer</flux:heading>

{{ $order->customer?->name ?: 'Guest checkout' }}

{{ $order->email }}

                @if ($order->customer)
                    <flux:button :href="route('admin.customers.show', $order->customer)" wire:navigate variant="filled" size="sm" class="mt-4">
                        View customer
                    </flux:button>
                @endif

                <flux:heading size="lg">Summary</flux:heading>

                        Subtotal
                        {{ \App\Support\Money::format($order->subtotal_amount, $order->currency) }}

                        Discount
                        -{{ \App\Support\Money::format($order->discount_amount, $order->currency) }}

                        Shipping
                        {{ \App\Support\Money::format($order->shipping_amount, $order->currency) }}

                        Tax
                        {{ \App\Support\Money::format($order->tax_amount, $order->currency) }}

                        Total
                        {{ \App\Support\Money::format($order->total_amount, $order->currency) }}

                <flux:heading size="lg">Refunds</flux:heading>

                    @forelse ($order->refunds as $refund)

getKey() }}">

{{ \App\Support\Money::format($refund->amount, $order->currency) }}

{{ $refund->reason ?: 'No reason' }}

                            <flux:badge>{{ Str::headline($refund->status->value) }}</flux:badge>

                    @empty

No refunds processed.

                    @endforelse

    <flux:modal name="refund-order" class="md:w-[32rem]">
        <form wire:submit="processRefund" class="space-y-6">

                <flux:heading size="lg">Process refund</flux:heading>
                <flux:text class="mt-2">Refundable amount: {{ \App\Support\Money::format($refundableAmount, $order->currency) }}</flux:text>


sed -n '1,220p' resources/views/livewire/storefront/account/orders/show.blade.php

<x-storefront.account-shell :customer="$customer">
    <x-storefront.breadcrumbs :items="[
        ['label' => 'Account', 'url' => route('account.dashboard')],
        ['label' => 'Orders', 'url' => route('account.orders.index')],
        ['label' => $order->order_number],
    ]" />

Order {{ $order->order_number }}

Placed on {{ $order->placed_at?->format('F j, Y') }}

                <flux:heading size="lg">Items</flux:heading>

                    @foreach ($order->lines as $line)

getKey() }}">

{{ $line->title_snapshot }}

Qty {{ $line->quantity }}

                            <x-storefront.price :amount="$line->total_amount" :currency="$order->currency" />

                    @endforeach

                    <flux:heading size="lg">Shipping Address</flux:heading>
                    @php($shippingAddress = $order->shipping_address_json ?? [])

{{ trim(data_get($shippingAddress, 'first_name').' '.data_get($shippingAddress, 'last_name')) }}

{{ data_get($shippingAddress, 'address1') }}

                        @if (data_get($shippingAddress, 'address2'))

{{ data_get($shippingAddress, 'address2') }}

                        @endif

{{ trim(data_get($shippingAddress, 'postal_code').' '.data_get($shippingAddress, 'city')) }}

{{ data_get($shippingAddress, 'country') }}

                    <flux:heading size="lg">Payment</flux:heading>

{{ Str::headline($order->payment_method->value) }}

                            <flux:badge>{{ Str::headline($order->financial_status->value) }}</flux:badge>
                            <flux:badge>{{ Str::headline($order->fulfillment_status->value) }}</flux:badge>

            @if ($order->fulfillments->isNotEmpty())

                    <flux:heading size="lg">Fulfillment</flux:heading>

                        @foreach ($order->fulfillments as $fulfillment)

getKey() }}">

                                    {{ Str::headline($fulfillment->status->value) }}
                                    @if ($fulfillment->tracking_number)
                                        {{ $fulfillment->tracking_number }}
                                    @endif

                        @endforeach

            @endif

Summary

                <flux:badge>{{ Str::headline($order->financial_status->value) }}</flux:badge>
                <flux:badge>{{ Str::headline($order->fulfillment_status->value) }}</flux:badge>

                    Subtotal
                    <x-storefront.price :amount="$order->subtotal_amount" :currency="$order->currency" />

                    Discount
                    -{{ \App\Support\Money::format($order->discount_amount, $order->currency) }}

                    Shipping
                    <x-storefront.price :amount="$order->shipping_amount" :currency="$order->currency" />

                    Tax
                    <x-storefront.price :amount="$order->tax_amount" :currency="$order->currency" />

                    Total
                    <x-storefront.price :amount="$order->total_amount" :currency="$order->currency" />

</x-storefront.account-shell>


rg -n "title_snapshot|sku_snapshot|discount_allocations_json|tax_lines_json" resources/views/livewire/admin/orders resources/views/livewire/storefront/account/orders resources/views/livewire/storefront/checkout -S

rg -n 'title_snapshot|sku_snapshot|discount_allocations_json|tax_lines_json' resources/views/livewire/admin/orders resources/views/livewire/storefront/account/orders resources/views/livewire/storefront/checkout -S

Question: title_snapshot|sku_snapshot|discount_allocations_json|tax_lines_json

resources/views/livewire/storefront/checkout/confirmation.blade.php:62:
{{ $line->title_snapshot }}

resources/views/livewire/admin/orders/show.blade.php:102:
{{ $line->title_snapshot }}

resources/views/livewire/admin/orders/show.blade.php:103:
{{ $line->sku_snapshot ?: 'No SKU' }}

resources/views/livewire/admin/orders/show.blade.php:205:                                        {{ $line->orderLine?->title_snapshot }} · Qty {{ $line->quantity }}
resources/views/livewire/admin/orders/show.blade.php:311:                        label="{{ $line->title_snapshot }} ({{ $remaining }} remaining)"
resources/views/livewire/storefront/account/orders/show.blade.php:21:
{{ $line->title_snapshot }}


Output:
Chunk ID: e02d1a
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 258
Output:
resources/views/livewire/storefront/checkout/confirmation.blade.php:62:
{{ $line->title_snapshot }}

resources/views/livewire/admin/orders/show.blade.php:102:
{{ $line->title_snapshot }}

resources/views/livewire/admin/orders/show.blade.php:103:
{{ $line->sku_snapshot ?: 'No SKU' }}

resources/views/livewire/admin/orders/show.blade.php:205:                                        {{ $line->orderLine?->title_snapshot }} · Qty {{ $line->quantity }}
resources/views/livewire/admin/orders/show.blade.php:311:                        label="{{ $line->title_snapshot }} ({{ $remaining }} remaining)"
resources/views/livewire/storefront/account/orders/show.blade.php:21:
{{ $line->title_snapshot }}


Output:
Chunk ID: 4c29a7
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 4394
Output:

            <flux:button :href="route('admin.orders.index')" wire:navigate variant="ghost" icon="arrow-left">
                Orders
            </flux:button>

                <flux:heading size="xl">{{ $order->order_number }}</flux:heading>
                <flux:text class="mt-1">{{ $order->email }} · {{ $order->placed_at?->format('M j, Y H:i') }}</flux:text>

            @if ($order->payment_method === \App\Enums\PaymentMethod::BankTransfer && $order->financial_status === \App\Enums\FinancialStatus::Pending)
                <flux:button wire:click="confirmBankTransferPayment" variant="primary" icon="banknotes" data-test="confirm-payment-button">
                    Confirm payment
                </flux:button>
            @endif

            @if (in_array($order->financial_status, [\App\Enums\FinancialStatus::Paid, \App\Enums\FinancialStatus::PartiallyRefunded], true) && $refundableAmount > 0)
                <flux:modal.trigger name="refund-order">
                    <flux:button variant="danger" icon="receipt-refund" data-test="refund-modal-button">
                        Refund
                    </flux:button>
                </flux:modal.trigger>
            @endif

            @if (in_array($order->financial_status, [\App\Enums\FinancialStatus::Paid, \App\Enums\FinancialStatus::PartiallyRefunded], true) && collect($remainingFulfillmentQuantities)->sum() > 0)
                <flux:modal.trigger name="fulfillment-order">
                    <flux:button variant="filled" icon="truck" data-test="fulfillment-modal-button">
                        Create fulfillment
                    </flux:button>
                </flux:modal.trigger>
            @endif

    @if ($actionMessage !== '')
        <flux:callout color="green" icon="check-circle" data-test="order-action-message">{{ $actionMessage }}</flux:callout>
    @endif

    @error('orderAction')

            {{ $message }}

    @enderror

    @error('fulfillment')

            {{ $message }}

    @enderror

    @if (! in_array($order->financial_status, [\App\Enums\FinancialStatus::Paid, \App\Enums\FinancialStatus::PartiallyRefunded], true) && collect($remainingFulfillmentQuantities)->sum() > 0)
        <flux:callout color="amber" icon="exclamation-triangle" data-test="fulfillment-guard-message">
            Cannot create fulfillment. Payment must be confirmed before items can be fulfilled. Current financial status: {{ Str::headline($order->financial_status->value) }}.
        </flux:callout>
    @endif

Order

                <flux:badge>{{ Str::headline($order->status->value) }}</flux:badge>

Payment

                <flux:badge :color="$order->financial_status->value === 'paid' ? 'green' : ($order->financial_status->value === 'pending' ? 'amber' : 'zinc')">
                    {{ Str::headline($order->financial_status->value) }}
                </flux:badge>

Fulfillment

                <flux:badge :color="$order->fulfillment_status->value === 'fulfilled' ? 'green' : ($order->fulfillment_status->value === 'partial' ? 'amber' : 'zinc')">
                    {{ Str::headline($order->fulfillment_status->value) }}
                </flux:badge>

Total

                {{ \App\Support\Money::format($order->total_amount, $order->currency) }}

                    <flux:heading size="lg">Line items</flux:heading>

                    @foreach ($order->lines as $line)

getKey() }}">

{{ $line->title_snapshot }}

{{ $line->sku_snapshot ?: 'No SKU' }}

Qty {{ $line->quantity }}

{{ \App\Support\Money::format($line->total_amount, $order->currency) }}

                    @endforeach

                    <flux:heading size="lg">Payments</flux:heading>

                    @foreach ($order->payments as $payment)

getKey() }}">

{{ Str::headline($payment->method->value) }}

{{ $payment->provider_payment_id }}

                                <flux:badge>{{ Str::headline($payment->status->value) }}</flux:badge>
                                {{ \App\Support\Money::format($payment->amount, $payment->currency) }}

                    @endforeach

                    <flux:heading size="lg">Timeline</flux:heading>

Order placed

{{ $order->placed_at?->format('M j, Y H:i') }}

                    @foreach ($order->payments as $payment)

getKey() }}">

                                    {{ $payment->status === \App\Enums\PaymentStatus::Captured ? 'Payment received' : Str::headline($payment->status->value) }}

{{ Str::headline($payment->method->value) }} · {{ \App\Support\Money::format($payment->amount, $payment->currency) }}

                    @endforeach

                    @foreach ($order->fulfillments as $fulfillment)

getKey() }}">

Fulfillment created

{{ Str::headline($fulfillment->status->value) }}

                    @endforeach

                    @foreach ($order->refunds as $refund)

getKey() }}">

Refunded

{{ \App\Support\Money::format($refund->amount, $order->currency) }} · {{ Str::headline($refund->status->value) }}

                    @endforeach

                    <flux:heading size="lg">Fulfillments</flux:heading>

                    @forelse ($order->fulfillments as $fulfillment)

getKey() }}">

                                    <flux:badge>{{ Str::headline($fulfillment->status->value) }}</flux:badge>
                                    @if ($fulfillment->tracking_number)

{{ $fulfillment->tracking_company }} {{ $fulfillment->tracking_number }}

                                    @endif

                                    @if ($fulfillment->status === \App\Enums\FulfillmentShipmentStatus::Pending)
                                        <flux:button wire:click="markFulfillmentShipped({{ $fulfillment->getKey() }})" size="sm" variant="filled" data-test="mark-fulfillment-shipped-button">Mark as shipped</flux:button>
                                    @endif
                                    @if ($fulfillment->status === \App\Enums\FulfillmentShipmentStatus::Shipped)
                                        <flux:button wire:click="markFulfillmentDelivered({{ $fulfillment->getKey() }})" size="sm" variant="filled" data-test="mark-fulfillment-delivered-button">Mark as delivered</flux:button>
                                    @endif

                                @foreach ($fulfillment->lines as $line)

getKey() }}">
                                        {{ $line->orderLine?->title_snapshot }} · Qty {{ $line->quantity }}

                                @endforeach

                    @empty

No fulfillments yet.

                    @endforelse

                <flux:heading size="lg">Customer</flux:heading>

{{ $order->customer?->name ?: 'Guest checkout' }}

{{ $order->email }}

                @if ($order->customer)
                    <flux:button :href="route('admin.customers.show', $order->customer)" wire:navigate variant="filled" size="sm" class="mt-4">
                        View customer
                    </flux:button>
                @endif

                <flux:heading size="lg">Summary</flux:heading>

                        Subtotal
                        {{ \App\Support\Money::format($order->subtotal_amount, $order->currency) }}

                        Discount
                        -{{ \App\Support\Money::format($order->discount_amount, $order->currency) }}

                        Shipping
                        {{ \App\Support\Money::format($order->shipping_amount, $order->currency) }}

                        Tax
                        {{ \App\Support\Money::format($order->tax_amount, $order->currency) }}

                        Total
                        {{ \App\Support\Money::format($order->total_amount, $order->currency) }}

                <flux:heading size="lg">Refunds</flux:heading>

                    @forelse ($order->refunds as $refund)

getKey() }}">

{{ \App\Support\Money::format($refund->amount, $order->currency) }}

{{ $refund->reason ?: 'No reason' }}

                            <flux:badge>{{ Str::headline($refund->status->value) }}</flux:badge>

                    @empty

No refunds processed.

                    @endforelse

    <flux:modal name="refund-order" class="md:w-[32rem]">
        <form wire:submit="processRefund" class="space-y-6">

                <flux:heading size="lg">Process refund</flux:heading>
                <flux:text class="mt-2">Refundable amount: {{ \App\Support\Money::format($refundableAmount, $order->currency) }}</flux:text>


Output:
Chunk ID: 4ee2f1
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 1667
Output:
<x-storefront.account-shell :customer="$customer">
    <x-storefront.breadcrumbs :items="[
        ['label' => 'Account', 'url' => route('account.dashboard')],
        ['label' => 'Orders', 'url' => route('account.orders.index')],
        ['label' => $order->order_number],
    ]" />

Order {{ $order->order_number }}

Placed on {{ $order->placed_at?->format('F j, Y') }}

                <flux:heading size="lg">Items</flux:heading>

                    @foreach ($order->lines as $line)

getKey() }}">

{{ $line->title_snapshot }}

Qty {{ $line->quantity }}

                            <x-storefront.price :amount="$line->total_amount" :currency="$order->currency" />

                    @endforeach

                    <flux:heading size="lg">Shipping Address</flux:heading>
                    @php($shippingAddress = $order->shipping_address_json ?? [])

{{ trim(data_get($shippingAddress, 'first_name').' '.data_get($shippingAddress, 'last_name')) }}

{{ data_get($shippingAddress, 'address1') }}

                        @if (data_get($shippingAddress, 'address2'))

{{ data_get($shippingAddress, 'address2') }}

                        @endif

{{ trim(data_get($shippingAddress, 'postal_code').' '.data_get($shippingAddress, 'city')) }}

{{ data_get($shippingAddress, 'country') }}

                    <flux:heading size="lg">Payment</flux:heading>

{{ Str::headline($order->payment_method->value) }}

                            <flux:badge>{{ Str::headline($order->financial_status->value) }}</flux:badge>
                            <flux:badge>{{ Str::headline($order->fulfillment_status->value) }}</flux:badge>

            @if ($order->fulfillments->isNotEmpty())

                    <flux:heading size="lg">Fulfillment</flux:heading>

                        @foreach ($order->fulfillments as $fulfillment)

getKey() }}">

                                    {{ Str::headline($fulfillment->status->value) }}
                                    @if ($fulfillment->tracking_number)
                                        {{ $fulfillment->tracking_number }}
                                    @endif

                        @endforeach

            @endif

Summary

                <flux:badge>{{ Str::headline($order->financial_status->value) }}</flux:badge>
                <flux:badge>{{ Str::headline($order->fulfillment_status->value) }}</flux:badge>

                    Subtotal
                    <x-storefront.price :amount="$order->subtotal_amount" :currency="$order->currency" />

                    Discount
                    -{{ \App\Support\Money::format($order->discount_amount, $order->currency) }}

                    Shipping
                    <x-storefront.price :amount="$order->shipping_amount" :currency="$order->currency" />

                    Tax
                    <x-storefront.price :amount="$order->tax_amount" :currency="$order->currency" />

                    Total
                    <x-storefront.price :amount="$order->total_amount" :currency="$order->currency" />

</x-storefront.account-shell>


sed -n '1,160p' app/Models/FulfillmentLine.php


sed -n '1,160p' app/Models/FulfillmentLine.php

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class FulfillmentLine extends Model
{
    /** @use HasFactory<\Database\Factories\FulfillmentLineFactory> */
    use HasFactory;

    public $timestamps = false;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'fulfillment_id',
        'order_line_id',
        'quantity',
    ];

    /**
     * @return BelongsTo<Fulfillment, $this>
     */
    public function fulfillment(): BelongsTo
    {
        return $this->belongsTo(Fulfillment::class);
    }

    /**
     * @return BelongsTo<OrderLine, $this>
     */
    public function orderLine(): BelongsTo
    {
        return $this->belongsTo(OrderLine::class);
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'quantity' => 'integer',
        ];
    }
}


Output:
Chunk ID: 2bf8e4
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 250
Output:
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class FulfillmentLine extends Model
{
    /** @use HasFactory<\Database\Factories\FulfillmentLineFactory> */
    use HasFactory;

    public $timestamps = false;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'fulfillment_id',
        'order_line_id',
        'quantity',
    ];

    /**
     * @return BelongsTo<Fulfillment, $this>
     */
    public function fulfillment(): BelongsTo
    {
        return $this->belongsTo(Fulfillment::class);
    }

    /**
     * @return BelongsTo<OrderLine, $this>
     */
    public function orderLine(): BelongsTo
    {
        return $this->belongsTo(OrderLine::class);
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'quantity' => 'integer',
        ];
    }
}


rg -n "create_store_users|store_users" database/migrations app/Models/StoreUser.php


rg -n "create_store_users|store_users" database/migrations app/Models/StoreUser.php

rg -n 'create_store_users|store_users' database/migrations app/Models/StoreUser.php

app/Models/StoreUser.php:16:    protected $table = 'store_users';
database/migrations/2026_05_03_211425_create_store_users_table.php:14:        Schema::create('store_users', function (Blueprint $table) {
database/migrations/2026_05_03_211425_create_store_users_table.php:31:        Schema::dropIfExists('store_users');


Output:
Chunk ID: 7bc638
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 80
Output:
app/Models/StoreUser.php:16:    protected $table = 'store_users';
database/migrations/2026_05_03_211425_create_store_users_table.php:14:        Schema::create('store_users', function (Blueprint $table) {
database/migrations/2026_05_03_211425_create_store_users_table.php:31:        Schema::dropIfExists('store_users');


sed -n '1,100p' database/migrations/2026_05_03_211425_create_store_users_table.php && sed -n '1,100p' app/Models/StoreUser.php


sed -n '1,100p' database/migrations/2026_05_03_211425_create_store_users_table.php && sed -n '1,100p' app/Models/StoreUser.php

StoreUser.php

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('store_users', function (Blueprint $table) {
            $table->foreignId('store_id')->constrained()->cascadeOnDelete();
            $table->foreignId('user_id')->constrained()->cascadeOnDelete();
            $table->enum('role', ['owner', 'admin', 'staff', 'support'])->default('staff');
            $table->timestamp('created_at')->nullable();

            $table->primary(['store_id', 'user_id']);
            $table->index('user_id');
            $table->index(['store_id', 'role']);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('store_users');
    }
};
<?php

namespace App\Models;

use App\Enums\StoreUserRole;
use Illuminate\Database\Eloquent\Relations\Pivot;

class StoreUser extends Pivot
{
    public $incrementing = false;

    public $timestamps = false;

    public const UPDATED_AT = null;

    protected $table = 'store_users';

    /**
     * @var list<string>
     */
    protected $fillable = [
        'store_id',
        'user_id',
        'role',
    ];

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'role' => StoreUserRole::class,
        ];
    }
}


Output:
Chunk ID: 01ec24
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 380
Output:
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('store_users', function (Blueprint $table) {
            $table->foreignId('store_id')->constrained()->cascadeOnDelete();
            $table->foreignId('user_id')->constrained()->cascadeOnDelete();
            $table->enum('role', ['owner', 'admin', 'staff', 'support'])->default('staff');
            $table->timestamp('created_at')->nullable();

            $table->primary(['store_id', 'user_id']);
            $table->index('user_id');
            $table->index(['store_id', 'role']);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('store_users');
    }
};
<?php

namespace App\Models;

use App\Enums\StoreUserRole;
use Illuminate\Database\Eloquent\Relations\Pivot;

class StoreUser extends Pivot
{
    public $incrementing = false;

    public $timestamps = false;

    public const UPDATED_AT = null;

    protected $table = 'store_users';

    /**
     * @var list<string>
     */
    protected $fillable = [
        'store_id',
        'user_id',
        'role',
    ];

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'role' => StoreUserRole::class,
        ];
    }
}


I’ve got enough context for the seed slice. The main change is straightforward, but it has a real test blast radius because existing tests used `#1001` as an ad hoc fixture; once the seeders own `#1001` through `#1015`, those tests need to use seeded data or expect the next checkout number.


Seed spec customers, addresses, orders, payments, fulfillments, refunds

Add seeder coverage test for deterministic order data

Update tests that previously created fixed #1001/#1005 fixtures

Run focused tests, browser suite, and full suite


Output: Plan updated


php artisan make:test --pest Seeders/SeededOrderDataTest --no-interaction


Output:
Chunk ID: 6ba6ae
Wall time: 0.2305 seconds
Process exited with code 0
Original token count: 22
Output:

   INFO  Test [tests/Feature/Seeders/SeededOrderDataTest.php] created successfully.


Output:
Chunk ID: 9d6304
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 0
Output:


php artisan make:test --pest Seeders/SeededOrderDataTest --no-interaction

INFO  Test [tests/Feature/Seeders/SeededOrderDataTest.php] created successfully.


I’m going to edit the seeders now: customers/addresses first, then orders and their related payment/fulfillment/refund records. I’ll keep the data deterministic and idempotent so rerunning `DatabaseSeeder` resets the same sample state.


Input:
*** Begin Patch
*** Update File: database/seeders/CustomerSeeder.php
@@
     public function run(): void
     {
-        $store = Store::query()->where('handle', 'acme-fashion')->firstOrFail();
-
-        Customer::withoutGlobalScopes()->updateOrCreate(
-            [
-                'store_id' => $store->getKey(),
-                'email' => 'customer@acme.test',
-            ],
-            [
-                'name' => 'John Doe',
-                'password' => 'password',
-                'marketing_opt_in' => true,
-            ],
-        );
+        foreach ($this->customers() as $storeHandle => $customers) {
+            $store = Store::query()->where('handle', $storeHandle)->firstOrFail();
+
+            foreach ($customers as $customer) {
+                Customer::withoutGlobalScopes()->updateOrCreate(
+                    [
+                        'store_id' => $store->getKey(),
+                        'email' => $customer['email'],
+                    ],
+                    [
+                        'name' => $customer['name'],
+                        'password' => 'password',
+                        'marketing_opt_in' => $customer['marketing_opt_in'],
+                    ],
+                );
+            }
+        }
+    }
+
+    /**
+     * @return array<string, list<array{email: string, name: string, marketing_opt_in: bool}>>
+     */
+    private function customers(): array
+    {
+        return [
+            'acme-fashion' => [
+                ['email' => 'customer@acme.test', 'name' => 'John Doe', 'marketing_opt_in' => true],
+                ['email' => 'jane@example.com', 'name' => 'Jane Smith', 'marketing_opt_in' => false],
+                ['email' => 'michael@example.com', 'name' => 'Michael Brown', 'marketing_opt_in' => true],
+                ['email' => 'sarah@example.com', 'name' => 'Sarah Wilson', 'marketing_opt_in' => false],
+                ['email' => 'david@example.com', 'name' => 'David Lee', 'marketing_opt_in' => true],
+                ['email' => 'emma@example.com', 'name' => 'Emma Garcia', 'marketing_opt_in' => false],
+                ['email' => 'james@example.com', 'name' => 'James Taylor', 'marketing_opt_in' => false],
+                ['email' => 'lisa@example.com', 'name' => 'Lisa Anderson', 'marketing_opt_in' => true],
+                ['email' => 'robert@example.com', 'name' => 'Robert Martinez', 'marketing_opt_in' => false],
+                ['email' => 'anna@example.com', 'name' => 'Anna Thomas', 'marketing_opt_in' => true],
+            ],
+            'acme-electronics' => [
+                ['email' => 'techfan@example.com', 'name' => 'Tech Fan', 'marketing_opt_in' => true],
+                ['email' => 'gadgetlover@example.com', 'name' => 'Gadget Lover', 'marketing_opt_in' => false],
+            ],
+        ];
     }
 }
*** End Patch


Success. Updated the following files:
M database/seeders/CustomerSeeder.php

@@ -15,15 +15,44 @@
     {
-        $store = Store::query()->where('handle', 'acme-fashion')->firstOrFail();
+        foreach ($this->customers() as $storeHandle => $customers) {
+            $store = Store::query()->where('handle', $storeHandle)->firstOrFail();

-        Customer::withoutGlobalScopes()->updateOrCreate(
-            [
-                'store_id' => $store->getKey(),
-                'email' => 'customer@acme.test',
+            foreach ($customers as $customer) {
+                Customer::withoutGlobalScopes()->updateOrCreate(
+                    [
+                        'store_id' => $store->getKey(),
+                        'email' => $customer['email'],
+                    ],
+                    [
+                        'name' => $customer['name'],
+                        'password' => 'password',
+                        'marketing_opt_in' => $customer['marketing_opt_in'],
+                    ],
+                );
+            }
+        }
+    }
+
+    /**
+     * @return array<string, list<array{email: string, name: string, marketing_opt_in: bool}>>
+     */
+    private function customers(): array
+    {
+        return [
+            'acme-fashion' => [
+                ['email' => 'customer@acme.test', 'name' => 'John Doe', 'marketing_opt_in' => true],
+                ['email' => 'jane@example.com', 'name' => 'Jane Smith', 'marketing_opt_in' => false],
+                ['email' => 'michael@example.com', 'name' => 'Michael Brown', 'marketing_opt_in' => true],
+                ['email' => 'sarah@example.com', 'name' => 'Sarah Wilson', 'marketing_opt_in' => false],
+                ['email' => 'david@example.com', 'name' => 'David Lee', 'marketing_opt_in' => true],
+                ['email' => 'emma@example.com', 'name' => 'Emma Garcia', 'marketing_opt_in' => false],
+                ['email' => 'james@example.com', 'name' => 'James Taylor', 'marketing_opt_in' => false],
+                ['email' => 'lisa@example.com', 'name' => 'Lisa Anderson', 'marketing_opt_in' => true],
+                ['email' => 'robert@example.com', 'name' => 'Robert Martinez', 'marketing_opt_in' => false],
+                ['email' => 'anna@example.com', 'name' => 'Anna Thomas', 'marketing_opt_in' => true],
             ],
-            [
-                'name' => 'John Doe',
-                'password' => 'password',
-                'marketing_opt_in' => true,
+            'acme-electronics' => [
+                ['email' => 'techfan@example.com', 'name' => 'Tech Fan', 'marketing_opt_in' => true],
+                ['email' => 'gadgetlover@example.com', 'name' => 'Gadget Lover', 'marketing_opt_in' => false],
             ],
-        );
+        ];
     }


Output: {"output":"Success. Updated the following files:\nM database/seeders/CustomerSeeder.php\n","metadata":{"exit_code":0,"duration_seconds":0.0}}


Input:
*** Begin Patch
*** Update File: database/seeders/CustomerAddressSeeder.php
@@
     public function run(): void
     {
-        $store = Store::query()->where('handle', 'acme-fashion')->firstOrFail();
-        $customer = Customer::withoutGlobalScopes()
-            ->where('store_id', $store->getKey())
-            ->where('email', 'customer@acme.test')
-            ->firstOrFail();
-
-        CustomerAddress::query()->updateOrCreate(
-            [
-                'customer_id' => $customer->getKey(),
-                'label' => 'Home',
-            ],
-            [
-                'address_json' => [
-                    'first_name' => 'John',
-                    'last_name' => 'Doe',
-                    'address1' => 'Main Street 1',
-                    'address2' => null,
-                    'city' => 'Berlin',
-                    'province_code' => null,
-                    'country' => 'DE',
-                    'postal_code' => '10115',
-                ],
-                'is_default' => true,
-            ],
-        );
+        foreach ($this->addresses() as $storeHandle => $addressesByEmail) {
+            $store = Store::query()->where('handle', $storeHandle)->firstOrFail();
+
+            foreach ($addressesByEmail as $email => $addresses) {
+                $customer = Customer::withoutGlobalScopes()
+                    ->where('store_id', $store->getKey())
+                    ->where('email', $email)
+                    ->firstOrFail();
+
+                CustomerAddress::query()
+                    ->where('customer_id', $customer->getKey())
+                    ->update(['is_default' => false]);
+
+                foreach ($addresses as $address) {
+                    CustomerAddress::query()->updateOrCreate(
+                        [
+                            'customer_id' => $customer->getKey(),
+                            'label' => $address['label'],
+                        ],
+                        [
+                            'address_json' => $address['address_json'],
+                            'is_default' => $address['is_default'],
+                        ],
+                    );
+                }
+            }
+        }
+    }
+
+    /**
+     * @return array<string, array<string, list<array{label: string, is_default: bool, address_json: array<string, string|null>}>>>
+     */
+    private function addresses(): array
+    {
+        return [
+            'acme-fashion' => [
+                'customer@acme.test' => [
+                    [
+                        'label' => 'Home',
+                        'is_default' => true,
+                        'address_json' => $this->address('John', 'Doe', 'Hauptstrasse 1', null, 'Berlin', null, '10115', '+49 30 12345678'),
+                    ],
+                    [
+                        'label' => 'Work',
+                        'is_default' => false,
+                        'address_json' => $this->address('John', 'Doe', 'Friedrichstrasse 100', 'Acme Corp, 3rd Floor', 'Berlin', null, '10117', '+49 30 87654321'),
+                    ],
+                ],
+                'jane@example.com' => [
+                    [
+                        'label' => 'Home',
+                        'is_default' => true,
+                        'address_json' => $this->address('Jane', 'Smith', 'Schillerstrasse 45', null, 'Munich', 'BY', '80336'),
+                    ],
+                ],
+                'michael@example.com' => [
+                    ['label' => 'Home', 'is_default' => true, 'address_json' => $this->address('Michael', 'Brown', 'Kantstrasse 12', null, 'Berlin', null, '10623')],
+                ],
+                'sarah@example.com' => [
+                    ['label' => 'Home', 'is_default' => true, 'address_json' => $this->address('Sarah', 'Wilson', 'Lindenweg 8', null, 'Hamburg', null, '20095')],
+                ],
+                'david@example.com' => [
+                    ['label' => 'Home', 'is_default' => true, 'address_json' => $this->address('David', 'Lee', 'Brueckenstrasse 22', null, 'Cologne', null, '50667')],
+                ],
+                'emma@example.com' => [
+                    ['label' => 'Home', 'is_default' => true, 'address_json' => $this->address('Emma', 'Garcia', 'Marktstrasse 5', null, 'Leipzig', null, '04109')],
+                ],
+                'james@example.com' => [
+                    ['label' => 'Home', 'is_default' => true, 'address_json' => $this->address('James', 'Taylor', 'Rosenstrasse 17', null, 'Stuttgart', null, '70173')],
+                ],
+                'lisa@example.com' => [
+                    ['label' => 'Home', 'is_default' => true, 'address_json' => $this->address('Lisa', 'Anderson', 'Bahnhofstrasse 31', null, 'Dusseldorf', null, '40210')],
+                ],
+                'robert@example.com' => [
+                    ['label' => 'Home', 'is_default' => true, 'address_json' => $this->address('Robert', 'Martinez', 'Goethestrasse 9', null, 'Frankfurt', null, '60313')],
+                ],
+                'anna@example.com' => [
+                    ['label' => 'Home', 'is_default' => true, 'address_json' => $this->address('Anna', 'Thomas', 'Lessingstrasse 14', null, 'Nuremberg', null, '90402')],
+                ],
+            ],
+            'acme-electronics' => [
+                'techfan@example.com' => [
+                    ['label' => 'Home', 'is_default' => true, 'address_json' => $this->address('Tech', 'Fan', 'Silicon Allee 7', null, 'Berlin', null, '10119')],
+                ],
+                'gadgetlover@example.com' => [
+                    ['label' => 'Home', 'is_default' => true, 'address_json' => $this->address('Gadget', 'Lover', 'Elektronstrasse 3', null, 'Munich', 'BY', '80331')],
+                ],
+            ],
+        ];
+    }
+
+    /**
+     * @return array<string, string|null>
+     */
+    private function address(
+        string $firstName,
+        string $lastName,
+        string $address1,
+        ?string $address2,
+        string $city,
+        ?string $provinceCode,
+        string $postalCode,
+        ?string $phone = null,
+    ): array {
+        return [
+            'first_name' => $firstName,
+            'last_name' => $lastName,
+            'address1' => $address1,
+            'address2' => $address2,
+            'city' => $city,
+            'province_code' => $provinceCode,
+            'country' => 'DE',
+            'postal_code' => $postalCode,
+            'phone' => $phone,
+        ];
     }
 }
*** End Patch


Success. Updated the following files:
M database/seeders/CustomerAddressSeeder.php

@@ -16,27 +16,117 @@
     {
-        $store = Store::query()->where('handle', 'acme-fashion')->firstOrFail();
-        $customer = Customer::withoutGlobalScopes()
-            ->where('store_id', $store->getKey())
-            ->where('email', 'customer@acme.test')
-            ->firstOrFail();
+        foreach ($this->addresses() as $storeHandle => $addressesByEmail) {
+            $store = Store::query()->where('handle', $storeHandle)->firstOrFail();
+
+            foreach ($addressesByEmail as $email => $addresses) {
+                $customer = Customer::withoutGlobalScopes()
+                    ->where('store_id', $store->getKey())
+                    ->where('email', $email)
+                    ->firstOrFail();
+
+                CustomerAddress::query()
+                    ->where('customer_id', $customer->getKey())
+                    ->update(['is_default' => false]);
+
+                foreach ($addresses as $address) {
+                    CustomerAddress::query()->updateOrCreate(
+                        [
+                            'customer_id' => $customer->getKey(),
+                            'label' => $address['label'],
+                        ],
+                        [
+                            'address_json' => $address['address_json'],
+                            'is_default' => $address['is_default'],
+                        ],
+                    );
+                }
+            }
+        }
+    }

-        CustomerAddress::query()->updateOrCreate(
-            [
-                'customer_id' => $customer->getKey(),
-                'label' => 'Home',
+    /**
+     * @return array<string, array<string, list<array{label: string, is_default: bool, address_json: array<string, string|null>}>>>
+     */
+    private function addresses(): array
+    {
+        return [
+            'acme-fashion' => [
+                'customer@acme.test' => [
+                    [
+                        'label' => 'Home',
+                        'is_default' => true,
+                        'address_json' => $this->address('John', 'Doe', 'Hauptstrasse 1', null, 'Berlin', null, '10115', '+49 30 12345678'),
+                    ],
+                    [
+                        'label' => 'Work',
+                        'is_default' => false,
+                        'address_json' => $this->address('John', 'Doe', 'Friedrichstrasse 100', 'Acme Corp, 3rd Floor', 'Berlin', null, '10117', '+49 30 87654321'),
+                    ],
+                ],
+                'jane@example.com' => [
+                    [
+                        'label' => 'Home',
+                        'is_default' => true,
+                        'address_json' => $this->address('Jane', 'Smith', 'Schillerstrasse 45', null, 'Munich', 'BY', '80336'),
+                    ],
+                ],
+                'michael@example.com' => [
+                    ['label' => 'Home', 'is_default' => true, 'address_json' => $this->address('Michael', 'Brown', 'Kantstrasse 12', null, 'Berlin', null, '10623')],
+                ],
+                'sarah@example.com' => [
+                    ['label' => 'Home', 'is_default' => true, 'address_json' => $this->address('Sarah', 'Wilson', 'Lindenweg 8', null, 'Hamburg', null, '20095')],
+                ],
+                'david@example.com' => [
+                    ['label' => 'Home', 'is_default' => true, 'address_json' => $this->address('David', 'Lee', 'Brueckenstrasse 22', null, 'Cologne', null, '50667')],
+                ],
+                'emma@example.com' => [
+                    ['label' => 'Home', 'is_default' => true, 'address_json' => $this->address('Emma', 'Garcia', 'Marktstrasse 5', null, 'Leipzig', null, '04109')],
+                ],
+                'james@example.com' => [
+                    ['label' => 'Home', 'is_default' => true, 'address_json' => $this->address('James', 'Taylor', 'Rosenstrasse 17', null, 'Stuttgart', null, '70173')],
+                ],
+                'lisa@example.com' => [
+                    ['label' => 'Home', 'is_default' => true, 'address_json' => $this->address('Lisa', 'Anderson', 'Bahnhofstrasse 31', null, 'Dusseldorf', null, '40210')],
+                ],
+                'robert@example.com' => [
+                    ['label' => 'Home', 'is_default' => true, 'address_json' => $this->address('Robert', 'Martinez', 'Goethestrasse 9', null, 'Frankfurt', null, '60313')],
+                ],
+                'anna@example.com' => [
+                    ['label' => 'Home', 'is_default' => true, 'address_json' => $this->address('Anna', 'Thomas', 'Lessingstrasse 14', null, 'Nuremberg', null, '90402')],
+                ],
             ],
-            [
-                'address_json' => [
-                    'first_name' => 'John',
-                    'last_name' => 'Doe',
-                    'address1' => 'Main Street 1',
-                    'address2' => null,
-                    'city' => 'Berlin',
-                    'province_code' => null,
-                    'country' => 'DE',
-                    'postal_code' => '10115',
+            'acme-electronics' => [
+                'techfan@example.com' => [
+                    ['label' => 'Home', 'is_default' => true, 'address_json' => $this->address('Tech', 'Fan', 'Silicon Allee 7', null, 'Berlin', null, '10119')],
+                ],
+                'gadgetlover@example.com' => [
+                    ['label' => 'Home', 'is_default' => true, 'address_json' => $this->address('Gadget', 'Lover', 'Elektronstrasse 3', null, 'Munich', 'BY', '80331')],
                 ],
-                'is_default' => true,
             ],
-        );
+        ];
+    }
+
+    /**
+     * @return array<string, string|null>
+     */
+    private function address(
+        string $firstName,
+        string $lastName,
+        string $address1,
+        ?string $address2,
+        string $city,
+        ?string $provinceCode,
+        string $postalCode,
+        ?string $phone = null,
+    ): array {
+        return [
+            'first_name' => $firstName,
+            'last_name' => $lastName,
+            'address1' => $address1,
+            'address2' => $address2,
+            'city' => $city,
+            'province_code' => $provinceCode,
+            'country' => 'DE',
+            'postal_code' => $postalCode,
+            'phone' => $phone,
+        ];
     }


Output: {"output":"Success. Updated the following files:\nM database/seeders/CustomerAddressSeeder.php\n","metadata":{"exit_code":0,"duration_seconds":0.0}}


Input:
*** Begin Patch
*** Update File: database/seeders/OrderSeeder.php
@@
 namespace Database\Seeders;

+use App\Enums\FinancialStatus;
+use App\Enums\FulfillmentStatus;
+use App\Enums\OrderStatus;
+use App\Enums\PaymentMethod;
+use App\Models\Customer;
+use App\Models\CustomerAddress;
+use App\Models\Discount;
+use App\Models\Fulfillment;
+use App\Models\InventoryItem;
+use App\Models\Order;
+use App\Models\Product;
+use App\Models\ProductVariant;
+use App\Models\Store;
 use Illuminate\Database\Seeder;
+use Illuminate\Support\Facades\DB;

 class OrderSeeder extends Seeder
 {
     /**
      * Run the database seeds.
      */
     public function run(): void
     {
-        //
+        DB::transaction(function (): void {
+            foreach ($this->orders() as $storeHandle => $orders) {
+                $store = Store::query()->where('handle', $storeHandle)->firstOrFail();
+
+                $this->resetSeededOrders($store, array_column($orders, 'order_number'));
+
+                foreach ($orders as $orderData) {
+                    $this->createOrder($store, $orderData);
+                }
+            }
+
+            $this->reservePendingInventory();
+        });
+    }
+
+    /**
+     * @param  list<string>  $orderNumbers
+     */
+    private function resetSeededOrders(Store $store, array $orderNumbers): void
+    {
+        Order::withoutGlobalScopes()
+            ->where('store_id', $store->getKey())
+            ->whereIn('order_number', $orderNumbers)
+            ->get()
+            ->each(function (Order $order): void {
+                $order->refunds()->delete();
+                $order->payments()->delete();
+
+                $order->fulfillments()
+                    ->get()
+                    ->each(function (Fulfillment $fulfillment): void {
+                        $fulfillment->lines()->delete();
+                        $fulfillment->delete();
+                    });
+
+                $order->lines()->delete();
+            });
+    }
+
+    /**
+     * @param  array<string, mixed>  $orderData
+     */
+    private function createOrder(Store $store, array $orderData): void
+    {
+        $customer = Customer::withoutGlobalScopes()
+            ->where('store_id', $store->getKey())
+            ->where('email', $orderData['customer_email'])
+            ->firstOrFail();
+        $address = $this->defaultAddress($customer);
+
+        $order = Order::withoutGlobalScopes()->updateOrCreate(
+            [
+                'store_id' => $store->getKey(),
+                'order_number' => $orderData['order_number'],
+            ],
+            [
+                'customer_id' => $customer->getKey(),
+                'payment_method' => $orderData['payment_method'],
+                'status' => $orderData['status'],
+                'financial_status' => $orderData['financial_status'],
+                'fulfillment_status' => $orderData['fulfillment_status'],
+                'currency' => $store->default_currency,
+                'subtotal_amount' => $orderData['subtotal_amount'],
+                'discount_amount' => $orderData['discount_amount'],
+                'shipping_amount' => $orderData['shipping_amount'],
+                'tax_amount' => $orderData['tax_amount'],
+                'total_amount' => $orderData['total_amount'],
+                'email' => $customer->email,
+                'billing_address_json' => $address,
+                'shipping_address_json' => $address,
+                'placed_at' => $orderData['placed_at'],
+            ],
+        );
+
+        foreach ($orderData['lines'] as $lineData) {
+            $this->createOrderLine($store, $order, $lineData, (int) $orderData['tax_amount']);
+        }
+    }
+
+    /**
+     * @param  array<string, mixed>  $lineData
+     */
+    private function createOrderLine(Store $store, Order $order, array $lineData, int $orderTaxAmount): void
+    {
+        $product = Product::withoutGlobalScopes()
+            ->where('store_id', $store->getKey())
+            ->where('handle', $lineData['product'])
+            ->firstOrFail();
+        $variant = $this->variant($product, $lineData['options'] ?? []);
+        $discountAmount = (int) ($lineData['discount_amount'] ?? 0);
+
+        $order->lines()->create([
+            'product_id' => $product->getKey(),
+            'variant_id' => $variant->getKey(),
+            'title_snapshot' => $this->titleSnapshot($product, $lineData['options'] ?? []),
+            'sku_snapshot' => $variant->sku,
+            'quantity' => $lineData['quantity'],
+            'unit_price_amount' => $lineData['unit_price_amount'],
+            'total_amount' => $lineData['total_amount'],
+            'tax_lines_json' => $orderTaxAmount > 0 ? [[
+                'title' => 'VAT',
+                'rate_bps' => 1900,
+                'amount' => $orderTaxAmount,
+            ]] : [],
+            'discount_allocations_json' => $discountAmount > 0 ? [[
+                'discount_id' => $this->welcomeDiscount($store)->getKey(),
+                'code' => 'WELCOME10',
+                'amount' => $discountAmount,
+            ]] : [],
+        ]);
+    }
+
+    /**
+     * @param  array<string, string>  $options
+     */
+    private function variant(Product $product, array $options): ProductVariant
+    {
+        $query = ProductVariant::withoutGlobalScopes()
+            ->where('product_id', $product->getKey());
+
+        foreach ($options as $optionName => $value) {
+            $query->whereHas('optionValues', function ($query) use ($optionName, $value): void {
+                $query
+                    ->withoutGlobalScopes()
+                    ->where('value', $value)
+                    ->whereHas('option', fn ($query) => $query
+                        ->withoutGlobalScopes()
+                        ->where('name', $optionName));
+            });
+        }
+
+        return $query->oldest('position')->firstOrFail();
+    }
+
+    /**
+     * @param  array<string, string>  $options
+     */
+    private function titleSnapshot(Product $product, array $options): string
+    {
+        if ($options === []) {
+            return $product->title;
+        }
+
+        return $product->title.' - '.implode(' / ', array_values($options));
+    }
+
+    /**
+     * @return array<string, mixed>
+     */
+    private function defaultAddress(Customer $customer): array
+    {
+        $address = CustomerAddress::query()
+            ->where('customer_id', $customer->getKey())
+            ->orderByDesc('is_default')
+            ->oldest('id')
+            ->firstOrFail();
+
+        return $address->address_json ?? [];
+    }
+
+    private function welcomeDiscount(Store $store): Discount
+    {
+        return Discount::withoutGlobalScopes()
+            ->where('store_id', $store->getKey())
+            ->where('code', 'WELCOME10')
+            ->firstOrFail();
+    }
+
+    private function reservePendingInventory(): void
+    {
+        $reservations = Order::withoutGlobalScopes()
+            ->with('lines')
+            ->where('financial_status', FinancialStatus::Pending->value)
+            ->whereIn('order_number', ['#1005', '#5003'])
+            ->get()
+            ->flatMap(fn (Order $order) => $order->lines)
+            ->filter(fn ($line): bool => $line->variant_id !== null)
+            ->groupBy('variant_id')
+            ->map(fn ($lines): int => (int) $lines->sum('quantity'));
+
+        $reservations->each(function (int $quantity, int $variantId): void {
+            InventoryItem::withoutGlobalScopes()
+                ->where('variant_id', $variantId)
+                ->update(['quantity_reserved' => $quantity]);
+        });
+    }
+
+    /**
+     * @return array<string, list<array<string, mixed>>>
+     */
+    private function orders(): array
+    {
+        return [
+            'acme-fashion' => [
+                $this->order('#1001', 'customer@acme.test', PaymentMethod::CreditCard, OrderStatus::Paid, FinancialStatus::Paid, FulfillmentStatus::Unfulfilled, 4998, 0, 499, 798, 5497, now()->subDays(2), [
+                    $this->line('classic-cotton-t-shirt', ['Size' => 'S', 'Color' => 'White'], 2, 2499, 4998),
+                ]),
+                $this->order('#1002', 'customer@acme.test', PaymentMethod::CreditCard, OrderStatus::Fulfilled, FinancialStatus::Paid, FulfillmentStatus::Fulfilled, 8498, 0, 499, 1357, 8997, now()->subDays(10), [
+                    $this->line('organic-hoodie', ['Size' => 'M'], 1, 5999, 5999),
+                    $this->line('classic-cotton-t-shirt', ['Size' => 'L', 'Color' => 'Black'], 1, 2499, 2499),
+                ]),
+                $this->order('#1003', 'jane@example.com', PaymentMethod::CreditCard, OrderStatus::Paid, FinancialStatus::Paid, FulfillmentStatus::Partial, 11498, 0, 499, 1836, 11997, now()->subDays(5), [
+                    $this->line('premium-slim-fit-jeans', ['Size' => '32', 'Color' => 'Blue'], 1, 7999, 7999),
+                    $this->line('leather-belt', ['Size' => 'L/XL', 'Color' => 'Brown'], 1, 3499, 3499),
+                ]),
+                $this->order('#1004', 'customer@acme.test', PaymentMethod::CreditCard, OrderStatus::Cancelled, FinancialStatus::Refunded, FulfillmentStatus::Unfulfilled, 2499, 0, 499, 399, 2998, now()->subDays(15), [
+                    $this->line('classic-cotton-t-shirt', ['Size' => 'M', 'Color' => 'Navy'], 1, 2499, 2499),
+                ]),
+                $this->order('#1005', 'jane@example.com', PaymentMethod::BankTransfer, OrderStatus::Pending, FinancialStatus::Pending, FulfillmentStatus::Unfulfilled, 3499, 0, 499, 559, 3998, now()->subHours(2), [
+                    $this->line('leather-belt', ['Size' => 'S/M', 'Color' => 'Black'], 1, 3499, 3499),
+                ]),
+                $this->order('#1006', 'michael@example.com', PaymentMethod::CreditCard, OrderStatus::Paid, FinancialStatus::Paid, FulfillmentStatus::Unfulfilled, 11999, 0, 499, 1916, 12498, now()->subDay(), [
+                    $this->line('running-sneakers', ['Size' => 'EU 42', 'Color' => 'Black'], 1, 11999, 11999),
+                ]),
+                $this->order('#1007', 'sarah@example.com', PaymentMethod::Paypal, OrderStatus::Fulfilled, FinancialStatus::Paid, FulfillmentStatus::Fulfilled, 9997, 0, 499, 1596, 10496, now()->subDays(20), [
+                    $this->line('v-neck-linen-tee', ['Size' => 'M', 'Color' => 'Beige'], 2, 3499, 6998),
+                    $this->line('wool-scarf', ['Color' => 'Grey'], 1, 2999, 2999),
+                ]),
+                $this->order('#1008', 'david@example.com', PaymentMethod::CreditCard, OrderStatus::Paid, FinancialStatus::PartiallyRefunded, FulfillmentStatus::Fulfilled, 8498, 0, 499, 1357, 8997, now()->subDays(12), [
+                    $this->line('cargo-pants', ['Size' => '32', 'Color' => 'Khaki'], 1, 5499, 5499),
+                    $this->line('graphic-print-tee', ['Size' => 'L'], 1, 2999, 2999),
+                ]),
+                $this->order('#1009', 'emma@example.com', PaymentMethod::CreditCard, OrderStatus::Paid, FinancialStatus::Paid, FulfillmentStatus::Unfulfilled, 4498, 0, 499, 718, 4997, now()->subDays(3), [
+                    $this->line('canvas-tote-bag', ['Color' => 'Natural'], 1, 1999, 1999),
+                    $this->line('bucket-hat', ['Size' => 'S/M', 'Color' => 'Black'], 1, 2499, 2499),
+                ]),
+                $this->order('#1010', 'customer@acme.test', PaymentMethod::Paypal, OrderStatus::Paid, FinancialStatus::Paid, FulfillmentStatus::Unfulfilled, 49999, 0, 499, 7983, 50498, now()->subDay(), [
+                    $this->line('cashmere-overcoat', ['Size' => 'M', 'Color' => 'Camel'], 1, 49999, 49999),
+                ]),
+                $this->order('#1011', 'james@example.com', PaymentMethod::CreditCard, OrderStatus::Paid, FinancialStatus::Paid, FulfillmentStatus::Fulfilled, 2799, 0, 499, 447, 3298, now()->subDays(25), [
+                    $this->line('striped-polo-shirt', ['Size' => 'XL'], 1, 2799, 2799),
+                ]),
+                $this->order('#1012', 'lisa@example.com', PaymentMethod::CreditCard, OrderStatus::Paid, FinancialStatus::Paid, FulfillmentStatus::Unfulfilled, 7998, 0, 499, 1277, 8497, now()->subDays(4), [
+                    $this->line('chino-shorts', ['Size' => '34', 'Color' => 'Navy'], 2, 3999, 7998),
+                ]),
+                $this->order('#1013', 'robert@example.com', PaymentMethod::CreditCard, OrderStatus::Paid, FinancialStatus::Paid, FulfillmentStatus::Unfulfilled, 7998, 0, 499, 1277, 8497, now()->subDay(), [
+                    $this->line('wide-leg-trousers', ['Size' => 'M'], 1, 4999, 4999),
+                    $this->line('wool-scarf', ['Color' => 'Burgundy'], 1, 2999, 2999),
+                ]),
+                $this->order('#1014', 'anna@example.com', PaymentMethod::CreditCard, OrderStatus::Paid, FinancialStatus::Paid, FulfillmentStatus::Fulfilled, 5000, 0, 0, 798, 5000, now()->subDays(14), [
+                    $this->line('gift-card', ['Amount' => '50 EUR'], 1, 5000, 5000),
+                ]),
+                $this->order('#1015', 'customer@acme.test', PaymentMethod::BankTransfer, OrderStatus::Paid, FinancialStatus::Paid, FulfillmentStatus::Unfulfilled, 5498, 550, 499, 790, 5447, now(), [
+                    $this->line('classic-cotton-t-shirt', ['Size' => 'M', 'Color' => 'White'], 1, 2499, 2499, 250),
+                    $this->line('graphic-print-tee', ['Size' => 'M'], 1, 2999, 2999, 300),
+                ]),
+            ],
+            'acme-electronics' => [
+                $this->order('#5001', 'techfan@example.com', PaymentMethod::CreditCard, OrderStatus::Fulfilled, FinancialStatus::Paid, FulfillmentStatus::Fulfilled, 121298, 0, 0, 0, 121298, now()->subDays(6), [
+                    $this->line('pro-laptop-15', ['Storage' => '512GB'], 1, 119999, 119999),
+                    $this->line('usb-c-cable-2m', [], 1, 1299, 1299),
+                ]),
+                $this->order('#5002', 'gadgetlover@example.com', PaymentMethod::CreditCard, OrderStatus::Paid, FinancialStatus::Paid, FulfillmentStatus::Unfulfilled, 14999, 0, 0, 0, 14999, now()->subDays(2), [
+                    $this->line('wireless-headphones', ['Color' => 'Black'], 1, 14999, 14999),
+                ]),
+                $this->order('#5003', 'techfan@example.com', PaymentMethod::BankTransfer, OrderStatus::Pending, FinancialStatus::Pending, FulfillmentStatus::Unfulfilled, 4999, 0, 0, 0, 4999, now()->subHours(6), [
+                    $this->line('monitor-stand', [], 1, 4999, 4999),
+                ]),
+            ],
+        ];
+    }
+
+    /**
+     * @param  list<array<string, mixed>>  $lines
+     * @return array<string, mixed>
+     */
+    private function order(
+        string $orderNumber,
+        string $customerEmail,
+        PaymentMethod $paymentMethod,
+        OrderStatus $status,
+        FinancialStatus $financialStatus,
+        FulfillmentStatus $fulfillmentStatus,
+        int $subtotalAmount,
+        int $discountAmount,
+        int $shippingAmount,
+        int $taxAmount,
+        int $totalAmount,
+        mixed $placedAt,
+        array $lines,
+    ): array {
+        return [
+            'order_number' => $orderNumber,
+            'customer_email' => $customerEmail,
+            'payment_method' => $paymentMethod,
+            'status' => $status,
+            'financial_status' => $financialStatus,
+            'fulfillment_status' => $fulfillmentStatus,
+            'subtotal_amount' => $subtotalAmount,
+            'discount_amount' => $discountAmount,
+            'shipping_amount' => $shippingAmount,
+            'tax_amount' => $taxAmount,
+            'total_amount' => $totalAmount,
+            'placed_at' => $placedAt,
+            'lines' => $lines,
+        ];
+    }
+
+    /**
+     * @param  array<string, string>  $options
+     * @return array<string, mixed>
+     */
+    private function line(
+        string $product,
+        array $options,
+        int $quantity,
+        int $unitPriceAmount,
+        int $totalAmount,
+        int $discountAmount = 0,
+    ): array {
+        return [
+            'product' => $product,
+            'options' => $options,
+            'quantity' => $quantity,
+            'unit_price_amount' => $unitPriceAmount,
+            'total_amount' => $totalAmount,
+            'discount_amount' => $discountAmount,
+        ];
     }
 }
*** End Patch


Success. Updated the following files:
M database/seeders/OrderSeeder.php

@@ -4,3 +4,17 @@

+use App\Enums\FinancialStatus;
+use App\Enums\FulfillmentStatus;
+use App\Enums\OrderStatus;
+use App\Enums\PaymentMethod;
+use App\Models\Customer;
+use App\Models\CustomerAddress;
+use App\Models\Discount;
+use App\Models\Fulfillment;
+use App\Models\InventoryItem;
+use App\Models\Order;
+use App\Models\Product;
+use App\Models\ProductVariant;
+use App\Models\Store;
 use Illuminate\Database\Seeder;
+use Illuminate\Support\Facades\DB;

@@ -13,3 +27,320 @@
     {
-        //
+        DB::transaction(function (): void {
+            foreach ($this->orders() as $storeHandle => $orders) {
+                $store = Store::query()->where('handle', $storeHandle)->firstOrFail();
+
+                $this->resetSeededOrders($store, array_column($orders, 'order_number'));
+
+                foreach ($orders as $orderData) {
+                    $this->createOrder($store, $orderData);
+                }
+            }
+
+            $this->reservePendingInventory();
+        });
+    }
+
+    /**
+     * @param  list<string>  $orderNumbers
+     */
+    private function resetSeededOrders(Store $store, array $orderNumbers): void
+    {
+        Order::withoutGlobalScopes()
+            ->where('store_id', $store->getKey())
+            ->whereIn('order_number', $orderNumbers)
+            ->get()
+            ->each(function (Order $order): void {
+                $order->refunds()->delete();
+                $order->payments()->delete();
+
+                $order->fulfillments()
+                    ->get()
+                    ->each(function (Fulfillment $fulfillment): void {
+                        $fulfillment->lines()->delete();
+                        $fulfillment->delete();
+                    });
+
+                $order->lines()->delete();
+            });
+    }
+
+    /**
+     * @param  array<string, mixed>  $orderData
+     */
+    private function createOrder(Store $store, array $orderData): void
+    {
+        $customer = Customer::withoutGlobalScopes()
+            ->where('store_id', $store->getKey())
+            ->where('email', $orderData['customer_email'])
+            ->firstOrFail();
+        $address = $this->defaultAddress($customer);
+
+        $order = Order::withoutGlobalScopes()->updateOrCreate(
+            [
+                'store_id' => $store->getKey(),
+                'order_number' => $orderData['order_number'],
+            ],
+            [
+                'customer_id' => $customer->getKey(),
+                'payment_method' => $orderData['payment_method'],
+                'status' => $orderData['status'],
+                'financial_status' => $orderData['financial_status'],
+                'fulfillment_status' => $orderData['fulfillment_status'],
+                'currency' => $store->default_currency,
+                'subtotal_amount' => $orderData['subtotal_amount'],
+                'discount_amount' => $orderData['discount_amount'],
+                'shipping_amount' => $orderData['shipping_amount'],
+                'tax_amount' => $orderData['tax_amount'],
+                'total_amount' => $orderData['total_amount'],
+                'email' => $customer->email,
+                'billing_address_json' => $address,
+                'shipping_address_json' => $address,
+                'placed_at' => $orderData['placed_at'],
+            ],
+        );
+
+        foreach ($orderData['lines'] as $lineData) {
+            $this->createOrderLine($store, $order, $lineData, (int) $orderData['tax_amount']);
+        }
+    }
+
+    /**
+     * @param  array<string, mixed>  $lineData
+     */
+    private function createOrderLine(Store $store, Order $order, array $lineData, int $orderTaxAmount): void
+    {
+        $product = Product::withoutGlobalScopes()
+            ->where('store_id', $store->getKey())
+            ->where('handle', $lineData['product'])
+            ->firstOrFail();
+        $variant = $this->variant($product, $lineData['options'] ?? []);
+        $discountAmount = (int) ($lineData['discount_amount'] ?? 0);
+
+        $order->lines()->create([
+            'product_id' => $product->getKey(),
+            'variant_id' => $variant->getKey(),
+            'title_snapshot' => $this->titleSnapshot($product, $lineData['options'] ?? []),
+            'sku_snapshot' => $variant->sku,
+            'quantity' => $lineData['quantity'],
+            'unit_price_amount' => $lineData['unit_price_amount'],
+            'total_amount' => $lineData['total_amount'],
+            'tax_lines_json' => $orderTaxAmount > 0 ? [[
+                'title' => 'VAT',
+                'rate_bps' => 1900,
+                'amount' => $orderTaxAmount,
+            ]] : [],
+            'discount_allocations_json' => $discountAmount > 0 ? [[
+                'discount_id' => $this->welcomeDiscount($store)->getKey(),
+                'code' => 'WELCOME10',
+                'amount' => $discountAmount,
+            ]] : [],
+        ]);
+    }
+
+    /**
+     * @param  array<string, string>  $options
+     */
+    private function variant(Product $product, array $options): ProductVariant
+    {
+        $query = ProductVariant::withoutGlobalScopes()
+            ->where('product_id', $product->getKey());
+
+        foreach ($options as $optionName => $value) {
+            $query->whereHas('optionValues', function ($query) use ($optionName, $value): void {
+                $query
+                    ->withoutGlobalScopes()
+                    ->where('value', $value)
+                    ->whereHas('option', fn ($query) => $query
+                        ->withoutGlobalScopes()
+                        ->where('name', $optionName));
+            });
+        }
+
+        return $query->oldest('position')->firstOrFail();
+    }
+
+    /**
+     * @param  array<string, string>  $options
+     */
+    private function titleSnapshot(Product $product, array $options): string
+    {
+        if ($options === []) {
+            return $product->title;
+        }
+
+        return $product->title.' - '.implode(' / ', array_values($options));
+    }
+
+    /**
+     * @return array<string, mixed>
+     */
+    private function defaultAddress(Customer $customer): array
+    {
+        $address = CustomerAddress::query()
+            ->where('customer_id', $customer->getKey())
+            ->orderByDesc('is_default')
+            ->oldest('id')
+            ->firstOrFail();
+
+        return $address->address_json ?? [];
+    }
+
+    private function welcomeDiscount(Store $store): Discount
+    {
+        return Discount::withoutGlobalScopes()
+            ->where('store_id', $store->getKey())
+            ->where('code', 'WELCOME10')
+            ->firstOrFail();
+    }
+
+    private function reservePendingInventory(): void
+    {
+        $reservations = Order::withoutGlobalScopes()
+            ->with('lines')
+            ->where('financial_status', FinancialStatus::Pending->value)
+            ->whereIn('order_number', ['#1005', '#5003'])
+            ->get()
+            ->flatMap(fn (Order $order) => $order->lines)
+            ->filter(fn ($line): bool => $line->variant_id !== null)
+            ->groupBy('variant_id')
+            ->map(fn ($lines): int => (int) $lines->sum('quantity'));
+
+        $reservations->each(function (int $quantity, int $variantId): void {
+            InventoryItem::withoutGlobalScopes()
+                ->where('variant_id', $variantId)
+                ->update(['quantity_reserved' => $quantity]);
+        });
+    }
+
+    /**
+     * @return array<string, list<array<string, mixed>>>
+     */
+    private function orders(): array
+    {
+        return [
+            'acme-fashion' => [
+                $this->order('#1001', 'customer@acme.test', PaymentMethod::CreditCard, OrderStatus::Paid, FinancialStatus::Paid, FulfillmentStatus::Unfulfilled, 4998, 0, 499, 798, 5497, now()->subDays(2), [
+                    $this->line('classic-cotton-t-shirt', ['Size' => 'S', 'Color' => 'White'], 2, 2499, 4998),
+                ]),
+                $this->order('#1002', 'customer@acme.test', PaymentMethod::CreditCard, OrderStatus::Fulfilled, FinancialStatus::Paid, FulfillmentStatus::Fulfilled, 8498, 0, 499, 1357, 8997, now()->subDays(10), [
+                    $this->line('organic-hoodie', ['Size' => 'M'], 1, 5999, 5999),
+                    $this->line('classic-cotton-t-shirt', ['Size' => 'L', 'Color' => 'Black'], 1, 2499, 2499),
+                ]),
+                $this->order('#1003', 'jane@example.com', PaymentMethod::CreditCard, OrderStatus::Paid, FinancialStatus::Paid, FulfillmentStatus::Partial, 11498, 0, 499, 1836, 11997, now()->subDays(5), [
+                    $this->line('premium-slim-fit-jeans', ['Size' => '32', 'Color' => 'Blue'], 1, 7999, 7999),
+                    $this->line('leather-belt', ['Size' => 'L/XL', 'Color' => 'Brown'], 1, 3499, 3499),
+                ]),
+                $this->order('#1004', 'customer@acme.test', PaymentMethod::CreditCard, OrderStatus::Cancelled, FinancialStatus::Refunded, FulfillmentStatus::Unfulfilled, 2499, 0, 499, 399, 2998, now()->subDays(15), [
+                    $this->line('classic-cotton-t-shirt', ['Size' => 'M', 'Color' => 'Navy'], 1, 2499, 2499),
+                ]),
+                $this->order('#1005', 'jane@example.com', PaymentMethod::BankTransfer, OrderStatus::Pending, FinancialStatus::Pending, FulfillmentStatus::Unfulfilled, 3499, 0, 499, 559, 3998, now()->subHours(2), [
+                    $this->line('leather-belt', ['Size' => 'S/M', 'Color' => 'Black'], 1, 3499, 3499),
+                ]),
+                $this->order('#1006', 'michael@example.com', PaymentMethod::CreditCard, OrderStatus::Paid, FinancialStatus::Paid, FulfillmentStatus::Unfulfilled, 11999, 0, 499, 1916, 12498, now()->subDay(), [
+                    $this->line('running-sneakers', ['Size' => 'EU 42', 'Color' => 'Black'], 1, 11999, 11999),
+                ]),
+                $this->order('#1007', 'sarah@example.com', PaymentMethod::Paypal, OrderStatus::Fulfilled, FinancialStatus::Paid, FulfillmentStatus::Fulfilled, 9997, 0, 499, 1596, 10496, now()->subDays(20), [
+                    $this->line('v-neck-linen-tee', ['Size' => 'M', 'Color' => 'Beige'], 2, 3499, 6998),
+                    $this->line('wool-scarf', ['Color' => 'Grey'], 1, 2999, 2999),
+                ]),
+                $this->order('#1008', 'david@example.com', PaymentMethod::CreditCard, OrderStatus::Paid, FinancialStatus::PartiallyRefunded, FulfillmentStatus::Fulfilled, 8498, 0, 499, 1357, 8997, now()->subDays(12), [
+                    $this->line('cargo-pants', ['Size' => '32', 'Color' => 'Khaki'], 1, 5499, 5499),
+                    $this->line('graphic-print-tee', ['Size' => 'L'], 1, 2999, 2999),
+                ]),
+                $this->order('#1009', 'emma@example.com', PaymentMethod::CreditCard, OrderStatus::Paid, FinancialStatus::Paid, FulfillmentStatus::Unfulfilled, 4498, 0, 499, 718, 4997, now()->subDays(3), [
+                    $this->line('canvas-tote-bag', ['Color' => 'Natural'], 1, 1999, 1999),
+                    $this->line('bucket-hat', ['Size' => 'S/M', 'Color' => 'Black'], 1, 2499, 2499),
+                ]),
+                $this->order('#1010', 'customer@acme.test', PaymentMethod::Paypal, OrderStatus::Paid, FinancialStatus::Paid, FulfillmentStatus::Unfulfilled, 49999, 0, 499, 7983, 50498, now()->subDay(), [
+                    $this->line('cashmere-overcoat', ['Size' => 'M', 'Color' => 'Camel'], 1, 49999, 49999),
+                ]),
+                $this->order('#1011', 'james@example.com', PaymentMethod::CreditCard, OrderStatus::Paid, FinancialStatus::Paid, FulfillmentStatus::Fulfilled, 2799, 0, 499, 447, 3298, now()->subDays(25), [
+                    $this->line('striped-polo-shirt', ['Size' => 'XL'], 1, 2799, 2799),
+                ]),
+                $this->order('#1012', 'lisa@example.com', PaymentMethod::CreditCard, OrderStatus::Paid, FinancialStatus::Paid, FulfillmentStatus::Unfulfilled, 7998, 0, 499, 1277, 8497, now()->subDays(4), [
+                    $this->line('chino-shorts', ['Size' => '34', 'Color' => 'Navy'], 2, 3999, 7998),
+                ]),
+                $this->order('#1013', 'robert@example.com', PaymentMethod::CreditCard, OrderStatus::Paid, FinancialStatus::Paid, FulfillmentStatus::Unfulfilled, 7998, 0, 499, 1277, 8497, now()->subDay(), [
+                    $this->line('wide-leg-trousers', ['Size' => 'M'], 1, 4999, 4999),
+                    $this->line('wool-scarf', ['Color' => 'Burgundy'], 1, 2999, 2999),
+                ]),
+                $this->order('#1014', 'anna@example.com', PaymentMethod::CreditCard, OrderStatus::Paid, FinancialStatus::Paid, FulfillmentStatus::Fulfilled, 5000, 0, 0, 798, 5000, now()->subDays(14), [
+                    $this->line('gift-card', ['Amount' => '50 EUR'], 1, 5000, 5000),
+                ]),
+                $this->order('#1015', 'customer@acme.test', PaymentMethod::BankTransfer, OrderStatus::Paid, FinancialStatus::Paid, FulfillmentStatus::Unfulfilled, 5498, 550, 499, 790, 5447, now(), [
+                    $this->line('classic-cotton-t-shirt', ['Size' => 'M', 'Color' => 'White'], 1, 2499, 2499, 250),
+                    $this->line('graphic-print-tee', ['Size' => 'M'], 1, 2999, 2999, 300),
+                ]),
+            ],
+            'acme-electronics' => [
+                $this->order('#5001', 'techfan@example.com', PaymentMethod::CreditCard, OrderStatus::Fulfilled, FinancialStatus::Paid, FulfillmentStatus::Fulfilled, 121298, 0, 0, 0, 121298, now()->subDays(6), [
+                    $this->line('pro-laptop-15', ['Storage' => '512GB'], 1, 119999, 119999),
+                    $this->line('usb-c-cable-2m', [], 1, 1299, 1299),
+                ]),
+                $this->order('#5002', 'gadgetlover@example.com', PaymentMethod::CreditCard, OrderStatus::Paid, FinancialStatus::Paid, FulfillmentStatus::Unfulfilled, 14999, 0, 0, 0, 14999, now()->subDays(2), [
+                    $this->line('wireless-headphones', ['Color' => 'Black'], 1, 14999, 14999),
+                ]),
+                $this->order('#5003', 'techfan@example.com', PaymentMethod::BankTransfer, OrderStatus::Pending, FinancialStatus::Pending, FulfillmentStatus::Unfulfilled, 4999, 0, 0, 0, 4999, now()->subHours(6), [
+                    $this->line('monitor-stand', [], 1, 4999, 4999),
+                ]),
+            ],
+        ];
+    }
+
+    /**
+     * @param  list<array<string, mixed>>  $lines
+     * @return array<string, mixed>
+     */
+    private function order(
+        string $orderNumber,
+        string $customerEmail,
+        PaymentMethod $paymentMethod,
+        OrderStatus $status,
+        FinancialStatus $financialStatus,
+        FulfillmentStatus $fulfillmentStatus,
+        int $subtotalAmount,
+        int $discountAmount,
+        int $shippingAmount,
+        int $taxAmount,
+        int $totalAmount,
+        mixed $placedAt,
+        array $lines,
+    ): array {
+        return [
+            'order_number' => $orderNumber,
+            'customer_email' => $customerEmail,
+            'payment_method' => $paymentMethod,
+            'status' => $status,
+            'financial_status' => $financialStatus,
+            'fulfillment_status' => $fulfillmentStatus,
+            'subtotal_amount' => $subtotalAmount,
+            'discount_amount' => $discountAmount,
+            'shipping_amount' => $shippingAmount,
+            'tax_amount' => $taxAmount,
+            'total_amount' => $totalAmount,
+            'placed_at' => $placedAt,
+            'lines' => $lines,
+        ];
+    }
+
+    /**
+     * @param  array<string, string>  $options
+     * @return array<string, mixed>
+     */
+    private function line(
+        string $product,
+        array $options,
+        int $quantity,
+        int $unitPriceAmount,
+        int $totalAmount,
+        int $discountAmount = 0,
+    ): array {
+        return [
+            'product' => $product,
+            'options' => $options,
+            'quantity' => $quantity,
+            'unit_price_amount' => $unitPriceAmount,
+            'total_amount' => $totalAmount,
+            'discount_amount' => $discountAmount,
+        ];
     }


Output: {"output":"Success. Updated the following files:\nM database/seeders/OrderSeeder.php\n","metadata":{"exit_code":0,"duration_seconds":0.0}}


Input:
*** Begin Patch
*** Update File: database/seeders/PaymentSeeder.php
@@
 namespace Database\Seeders;

+use App\Enums\PaymentMethod;
+use App\Enums\PaymentStatus;
+use App\Models\Order;
+use App\Models\Payment;
+use App\Models\Store;
 use Illuminate\Database\Seeder;
+use Illuminate\Support\Facades\DB;

 class PaymentSeeder extends Seeder
 {
     /**
      * Run the database seeds.
      */
     public function run(): void
     {
-        //
+        DB::transaction(function (): void {
+            foreach ($this->payments() as $storeHandle => $payments) {
+                $store = Store::query()->where('handle', $storeHandle)->firstOrFail();
+                $orders = Order::withoutGlobalScopes()
+                    ->where('store_id', $store->getKey())
+                    ->whereIn('order_number', array_keys($payments))
+                    ->get()
+                    ->keyBy('order_number');
+
+                Payment::query()
+                    ->whereIn('order_id', $orders->pluck('id'))
+                    ->delete();
+
+                foreach ($payments as $orderNumber => $paymentData) {
+                    $order = $orders->get($orderNumber);
+
+                    if (! $order instanceof Order) {
+                        continue;
+                    }
+
+                    Payment::query()->create([
+                        'order_id' => $order->getKey(),
+                        'provider' => 'mock',
+                        'method' => $paymentData['method'],
+                        'provider_payment_id' => $paymentData['provider_payment_id'],
+                        'status' => $paymentData['status'],
+                        'amount' => $paymentData['amount'],
+                        'currency' => $order->currency,
+                        'raw_json_encrypted' => [
+                            'success' => true,
+                            'status' => $paymentData['status']->value,
+                            'reference_id' => $paymentData['provider_payment_id'],
+                        ],
+                    ]);
+                }
+            }
+        });
+    }
+
+    /**
+     * @return array<string, array<string, array{method: PaymentMethod, provider_payment_id: string, status: PaymentStatus, amount: int}>>
+     */
+    private function payments(): array
+    {
+        return [
+            'acme-fashion' => [
+                '#1001' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order1001', PaymentStatus::Captured, 5497),
+                '#1002' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order1002', PaymentStatus::Captured, 8997),
+                '#1003' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order1003', PaymentStatus::Captured, 11997),
+                '#1004' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order1004', PaymentStatus::Refunded, 2998),
+                '#1005' => $this->payment(PaymentMethod::BankTransfer, 'mock_test_order1005', PaymentStatus::Pending, 3998),
+                '#1006' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order1006', PaymentStatus::Captured, 12498),
+                '#1007' => $this->payment(PaymentMethod::Paypal, 'mock_test_order1007', PaymentStatus::Captured, 10496),
+                '#1008' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order1008', PaymentStatus::Captured, 8997),
+                '#1009' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order1009', PaymentStatus::Captured, 4997),
+                '#1010' => $this->payment(PaymentMethod::Paypal, 'mock_test_order1010', PaymentStatus::Captured, 50498),
+                '#1011' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order1011', PaymentStatus::Captured, 3298),
+                '#1012' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order1012', PaymentStatus::Captured, 8497),
+                '#1013' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order1013', PaymentStatus::Captured, 8497),
+                '#1014' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order1014', PaymentStatus::Captured, 5000),
+                '#1015' => $this->payment(PaymentMethod::BankTransfer, 'mock_test_order1015', PaymentStatus::Captured, 5447),
+            ],
+            'acme-electronics' => [
+                '#5001' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order5001', PaymentStatus::Captured, 121298),
+                '#5002' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order5002', PaymentStatus::Captured, 14999),
+                '#5003' => $this->payment(PaymentMethod::BankTransfer, 'mock_test_order5003', PaymentStatus::Pending, 4999),
+            ],
+        ];
+    }
+
+    /**
+     * @return array{method: PaymentMethod, provider_payment_id: string, status: PaymentStatus, amount: int}
+     */
+    private function payment(PaymentMethod $method, string $providerPaymentId, PaymentStatus $status, int $amount): array
+    {
+        return [
+            'method' => $method,
+            'provider_payment_id' => $providerPaymentId,
+            'status' => $status,
+            'amount' => $amount,
+        ];
     }
 }
*** End Patch


Success. Updated the following files:
M database/seeders/PaymentSeeder.php

@@ -4,3 +4,9 @@

+use App\Enums\PaymentMethod;
+use App\Enums\PaymentStatus;
+use App\Models\Order;
+use App\Models\Payment;
+use App\Models\Store;
 use Illuminate\Database\Seeder;
+use Illuminate\Support\Facades\DB;

@@ -13,3 +19,83 @@
     {
-        //
+        DB::transaction(function (): void {
+            foreach ($this->payments() as $storeHandle => $payments) {
+                $store = Store::query()->where('handle', $storeHandle)->firstOrFail();
+                $orders = Order::withoutGlobalScopes()
+                    ->where('store_id', $store->getKey())
+                    ->whereIn('order_number', array_keys($payments))
+                    ->get()
+                    ->keyBy('order_number');
+
+                Payment::query()
+                    ->whereIn('order_id', $orders->pluck('id'))
+                    ->delete();
+
+                foreach ($payments as $orderNumber => $paymentData) {
+                    $order = $orders->get($orderNumber);
+
+                    if (! $order instanceof Order) {
+                        continue;
+                    }
+
+                    Payment::query()->create([
+                        'order_id' => $order->getKey(),
+                        'provider' => 'mock',
+                        'method' => $paymentData['method'],
+                        'provider_payment_id' => $paymentData['provider_payment_id'],
+                        'status' => $paymentData['status'],
+                        'amount' => $paymentData['amount'],
+                        'currency' => $order->currency,
+                        'raw_json_encrypted' => [
+                            'success' => true,
+                            'status' => $paymentData['status']->value,
+                            'reference_id' => $paymentData['provider_payment_id'],
+                        ],
+                    ]);
+                }
+            }
+        });
+    }
+
+    /**
+     * @return array<string, array<string, array{method: PaymentMethod, provider_payment_id: string, status: PaymentStatus, amount: int}>>
+     */
+    private function payments(): array
+    {
+        return [
+            'acme-fashion' => [
+                '#1001' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order1001', PaymentStatus::Captured, 5497),
+                '#1002' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order1002', PaymentStatus::Captured, 8997),
+                '#1003' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order1003', PaymentStatus::Captured, 11997),
+                '#1004' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order1004', PaymentStatus::Refunded, 2998),
+                '#1005' => $this->payment(PaymentMethod::BankTransfer, 'mock_test_order1005', PaymentStatus::Pending, 3998),
+                '#1006' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order1006', PaymentStatus::Captured, 12498),
+                '#1007' => $this->payment(PaymentMethod::Paypal, 'mock_test_order1007', PaymentStatus::Captured, 10496),
+                '#1008' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order1008', PaymentStatus::Captured, 8997),
+                '#1009' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order1009', PaymentStatus::Captured, 4997),
+                '#1010' => $this->payment(PaymentMethod::Paypal, 'mock_test_order1010', PaymentStatus::Captured, 50498),
+                '#1011' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order1011', PaymentStatus::Captured, 3298),
+                '#1012' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order1012', PaymentStatus::Captured, 8497),
+                '#1013' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order1013', PaymentStatus::Captured, 8497),
+                '#1014' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order1014', PaymentStatus::Captured, 5000),
+                '#1015' => $this->payment(PaymentMethod::BankTransfer, 'mock_test_order1015', PaymentStatus::Captured, 5447),
+            ],
+            'acme-electronics' => [
+                '#5001' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order5001', PaymentStatus::Captured, 121298),
+                '#5002' => $this->payment(PaymentMethod::CreditCard, 'mock_test_order5002', PaymentStatus::Captured, 14999),
+                '#5003' => $this->payment(PaymentMethod::BankTransfer, 'mock_test_order5003', PaymentStatus::Pending, 4999),
+            ],
+        ];
+    }
+
+    /**
+     * @return array{method: PaymentMethod, provider_payment_id: string, status: PaymentStatus, amount: int}
+     */
+    private function payment(PaymentMethod $method, string $providerPaymentId, PaymentStatus $status, int $amount): array
+    {
+        return [
+            'method' => $method,
+            'provider_payment_id' => $providerPaymentId,
+            'status' => $status,
+            'amount' => $amount,
+        ];
     }