<?php
namespace App\Http\Controllers\Api\V1;

use App\Helpers\ApiResponse;
use App\Http\Controllers\Api\BaseApiController;
use App\Models\PaymentInvoice;
use Symfony\Component\HttpFoundation\Response;


class PaymentInvoiceController extends BaseApiController
{

    public function getInvoceById($id)
    {
        try {
            $tenant = app('tenant.context');
            $fid = $tenant->franchiseeId;
            $columns = [
                "id",
                "registration_id",
                "franchisee_id",
                "customer_email",
                "class_and_customer_details",
                "payment_type",
                "payment_method",
                "subtotal",
                "tax",
                "total",
                "total",
                "currency",
                "status",
                "paid_at",
                "response",
            ];
            $invoices = PaymentInvoice::select($columns)
                ->where('registration_id', $id)
                ->first();

            if (!$invoices) {
                return ApiResponse::error(
                    'Recored not found based on this registration id. ',
                    Response::HTTP_NOT_FOUND
                );
            }

            return ApiResponse::success([
                $invoices,
            ], "Registration invoice d");


        } catch (\Throwable $e) {
            return ApiResponse::exception($e);
        }
    }



}
