<?php

namespace App\Http\Controllers\INSURANCE;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\INSURANCE\InsuranceType;

class InsuranceTypeController extends Controller
{
    public function index()
    {
        // Retrieve all root insurance types and recursively load their children
        $insuranceTypes = InsuranceType::whereNull('parent_id')
            ->with('childrenRecursive')
            ->get();

        return view('backend.insurance.insurance-types.index', compact('insuranceTypes'));
    }
}
