<?php

namespace App\Http\Controllers;

use App\Models\Area;
use App\Models\InventoryBrand;
use App\Models\InventoryCategory;
use App\Models\InventoryProductType;
use App\Models\InventorySubcategory;
use App\Models\InventorySupplier;
use Illuminate\Http\JsonResponse;

/**
 * Catálogos auxiliares del módulo inventario (no mezclar con productos de lavandería).
 */
class InventoryCatalogController extends Controller
{
    public function index(): JsonResponse
    {
        return response()->json([
            'data' => [
                'product_types' => InventoryProductType::query()->orderBy('sort_order')->get(['id', 'code', 'name', 'sort_order']),
                'brands' => InventoryBrand::query()->orderBy('name')->get(['id', 'name']),
                'categories' => InventoryCategory::query()->orderBy('name')->get(['id', 'name']),
                'subcategories' => InventorySubcategory::query()->orderBy('name')->get(['id', 'category_id', 'name']),
                'suppliers' => InventorySupplier::query()->orderBy('name')->get(['id', 'name', 'contact']),
                'areas' => Area::query()->where('is_active', true)->orderBy('name')->get(['id', 'code', 'name']),
            ],
            'meta' => null,
            'errors' => null,
        ], JsonResponse::HTTP_OK);
    }
}
