<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Invoice;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Carbon\Carbon;

class InvoiceController extends Controller
{
    public function index()
    {
        // Ambil semua tagihan, sertakan relasi user, profile, & meterReading
        $invoices = Invoice::with(['user.profile', 'meterReading']) 
                            ->orderBy('created_at', 'desc')
                            ->paginate(10);

        return response()->json($invoices);
    }
}