<?php

namespace App\Http\Controllers;

use App\Models\Booking;
use Illuminate\Http\Request;

class AgreementController extends Controller
{
    public function index()
    {
        $bookings = Booking::with(['customer', 'property.block.project'])->latest()->paginate(10);
        return view('agreements.index', compact('bookings'));
    }

    public function show(Booking $booking)
    {
        $booking->load(['customer', 'property.block.project']);
        $installmentPlan = \App\Models\InstallmentPlan::where('property_id', $booking->property_id)
            ->where('customer_id', $booking->customer_id)
            ->with('installments')
            ->first();

        return view('agreements.show', compact('booking', 'installmentPlan'));
    }
}
