<?php

namespace App\Controllers\Owner;

use App\Controllers\BaseController;
use App\Models\PaymentModel;

class PaymentController extends BaseController
{
    public function index()
    {
        $paymentModel = new PaymentModel();
        
        $data = [
            'title'    => 'Monitoring Pembayaran',
            // Pastikan join sudah benar sesuai database Anda
            'payments' => $paymentModel
                ->select('payments.*, orders.order_number, orders.customer_name, payment_methods.nama_metode')
                ->join('orders', 'orders.id_order = payments.id_order')
                ->join('payment_methods', 'payment_methods.id_payment_method = payments.id_payment_method', 'left')
                ->orderBy('payments.id_payment', 'DESC')
                ->findAll()
        ];

        // Pastikan path view sesuai dengan folder yang Anda tunjukkan di gambar kedua (payments/index.php)
        return view('owner/payments/index', $data);
    }
}