<?php

namespace Koneko\VuexyWarehouse\Providers;

use Illuminate\Support\ServiceProvider;
use Livewire\Livewire;
use Koneko\VuexyWarehouse\Livewire\Warehouses\{WarehouseIndex,WarehouseOffcanvasForm};
use OwenIt\Auditing\AuditableObserver;

class VuexyWarehouseServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        // Register the module's routes
        $this->loadRoutesFrom(__DIR__.'/../routes/admin.php');


        // Cargar vistas del paquete
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'vuexy-warehouse');


        // Register the migrations
        $this->loadMigrationsFrom(__DIR__ . '/../database/migrations');


        // Registrar Livewire Components
        $components = [
            'warehouse-index' => WarehouseIndex::class,
            'warehouse-offcanvas-form' => WarehouseOffcanvasForm::class,
            'product-index' => ProductIndex::class,
            'product-form' => ProductForm::class,
            'product-property-index' => ProductPropertyIndex::class,
            'product-property-offcanvas-form' => ProductPropertyOffcanvasForm::class,
            'product-category-index' => ProductCategoryIndex::class,
            'product-receipts-index' => ProductReceiptsIndex::class,
            'product-receipts-form' => ProductReceiptsForm::class,
            'inventory-index' => InventoryIndex::class,
            'inventory-movements-index' => InventoryMovementsIndex::class,
            'inventory-movements-form' => InventoryMovementsForm::class,
            'warehouse-transfer-index' => WarehouseTransferIndex::class,
            'warehouse-transfer-form' => WarehouseTransferForm::class,
        ];

        foreach ($components as $alias => $component) {
            Livewire::component($alias, $component);
        }


        // Registrar auditoría en usuarios
        //User::observe(AuditableObserver::class);
    }
}