<?php

namespace App\Http\Controllers;

use App\Support\ModuloPortal;
use Illuminate\Http\Request;
use Illuminate\View\View;

class ModuloPlaceholderController extends Controller
{
    public function __invoke(Request $request, string $slug): View
    {
        $modulo = ModuloPortal::encontrar($slug);

        abort_if(! $modulo || ($modulo['ativo'] ?? false), 404);
        abort_unless($request->user()->can($modulo['permissao']), 403);

        return view('modulos.placeholder', [
            'modulo' => $modulo,
        ]);
    }
}
