<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\View\View;

class SistemaController extends Controller
{
    public function show(Request $request, string $slug): View
    {
        $pagina = config("system_menu.pages.{$slug}");

        abort_if(! $pagina, 404);

        if ($pagina['permissao'] ?? null) {
            $this->authorize($pagina['permissao']);
        }

        return view('sistema.show', [
            'pagina' => $pagina,
            'slug' => $slug,
        ]);
    }
}
