<?php

namespace App\Modules\Payment;

use Illuminate\Http\Request;
use Mtc\Checkout\Contracts\PayableContract;
use Mtc\Checkout\Contracts\PayableFactoryContract;
use Mtc\VehicleReservations\ReservationRepository;

class ReservationFactory implements PayableFactoryContract
{
    public function __construct(private readonly ReservationRepository $repository)
    {
        //
    }

    public function create(Request $request): PayableContract
    {
        return match ($request->input('type')) {
            'reservation' => $this->repository->create($request->input()),
            default => throw new \Exception("Unsupported Payment Object"),
        };
    }
}
