<?php

namespace FluxCms\Core\Http\Controllers\Admin;

use FluxCms\Core\Services\ComponentRegistry;
use Illuminate\Routing\Controller;

class ComponentController extends Controller
{
    public function __construct()
    {
        $this->middleware('can:flux-cms.view');
    }

    public function __invoke()
    {
        $registry = app(ComponentRegistry::class);
        $components = $registry->getComponentsByCategory();
        $stats = $registry->getComponentStats();

        return view('flux-cms::admin.components.index', compact('components', 'stats'));
    }
}
