<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Http\Requests\CheckoutRequest;
use App\Models\CustomerReferralBalance;
use App\Http\Repositories\CheckoutRepository;

class CheckoutController extends Controller
{
    public function index()
    {
        $referral = CustomerReferralBalance::where('customer_id', Auth::guard('customer')->id())->first();

        return view('shop.checkout.index', compact('referral'));
    }

    public function Store(CheckoutRequest $request, CheckoutRepository $repository)
    {
        $order = $repository->processCheckout($request->all());
        return redirect()->route('checkout.success');
    }

    public function success()
    {
        return view('shop.checkout.success');
    }
}
