<?php

namespace App\Http\Controllers\Student;

use App\Http\Controllers\Admin\PageController;
use App\Models\Student;
use App\Services\Finance\BillingService;
use Illuminate\Http\Request;
use Illuminate\View\View;

class FeeController extends PageController
{
    public function __construct(private readonly BillingService $billingService) {}

    public function index(Request $request): View
    {
        $student = Student::query()->find(auth()->user()?->student_id);
        $statement = $student ? $this->billingService->studentStatement($student) : null;

        return $this->page('student.fees.index', [
            'crumbTitle' => 'My Fees',
            'crumbSub' => 'Balance & invoices',
            'student' => $student,
            'statement' => $statement,
        ]);
    }
}
