<?php

namespace App\Domains\Purchase\Services\Checkout;

use App\Domains\Purchase\Models\Purchase;

class PurchaseResponseLoader
{
    public function load(Purchase $purchase): Purchase
    {
        $relations = ['tenant', 'items.imageAttachment'];

        if (
            $purchase->status === Purchase::STATUS_IN_REVIEW
            && $purchase->payment_method === 'transfer'
        ) {
            $relations[] = 'telepagosPaymentCandidates.payment';
        }

        return $purchase->load($relations);
    }
}
