"dashboard", "description" => "Dashboard", "bits" => Permission::ALL_PERMS, "children" => [], ], [ "scope" => "franchisee", "description" => "Franqueados", "bits" => Permission::MENU | Permission::VIEW, "children" => [ [ "scope" => "unit", "description" => "Unidades", "bits" => Permission::ALL_PERMS, "children" => [], ], [ "scope" => "franchisee-unit", "description" => "Unidades do Franqueado", "bits" => Permission::ALL_PERMS, "children" => [], ], ], ], // Pacotes / Aulas [ "scope" => "class-package", "description" => "Pacotes (Franqueadora)", "bits" => Permission::ALL_PERMS, "children" => [], ], [ "scope" => "class-package-unit", "description" => "Pacotes (Unidade)", "bits" => Permission::ALL_PERMS, "children" => [], ], [ "scope" => "class-package-franchisee", "description" => "Pacotes (Franqueado)", "bits" => Permission::ALL_PERMS, "children" => [], ], [ "scope" => "class", "description" => "Aulas", "bits" => Permission::ALL_PERMS, "children" => [ [ "scope" => "class-attendance", "description" => "Frequência de Aulas", "bits" => Permission::ALL_PERMS, "children" => [], ], ], ], [ "scope" => "modality", "description" => "Modalidades", "bits" => Permission::ALL_PERMS, "children" => [], ], // Alunos [ "scope" => "student", "description" => "Alunos", "bits" => Permission::ALL_PERMS, "children" => [ [ "scope" => "student-history", "description" => "Histórico de Alunos", "bits" => Permission::ALL_PERMS, "children" => [], ], [ "scope" => "student-media", "description" => "Mídias de Alunos", "bits" => Permission::ALL_PERMS, "children" => [], ], [ "scope" => "student-responsible", "description" => "Responsáveis de Alunos", "bits" => Permission::ALL_PERMS, "children" => [], ], ], ], [ "scope" => "student-contract", "description" => "Contratos de Alunos", "bits" => Permission::ALL_PERMS, "children" => [], ], [ "scope" => "media", "description" => "Mídias", "bits" => Permission::ALL_PERMS, "children" => [], ], // Kanban [ "scope" => "kanban", "description" => "Kanban", "bits" => Permission::ALL_PERMS, "children" => [ [ "scope" => "kanban-status", "description" => "Status do Kanban", "bits" => Permission::ALL_PERMS, "children" => [], ], [ "scope" => "kanban-movement", "description" => "Movimentos do Kanban", "bits" => Permission::ALL_PERMS, "children" => [], ], ], ], // Suporte [ "scope" => "support-ticket", "description" => "Chamados de Suporte", "bits" => Permission::ALL_PERMS, "children" => [ [ "scope" => "support-status", "description" => "Status de Suporte", "bits" => Permission::ALL_PERMS, "children" => [], ], [ "scope" => "support-movement", "description" => "Movimentos de Suporte", "bits" => Permission::ALL_PERMS, "children" => [], ], ], ], // Notificações [ "scope" => "notification", "description" => "Notificações", "bits" => Permission::ALL_PERMS, "children" => [ [ "scope" => "notification-recipient", "description" => "Destinatários de Notificações", "bits" => Permission::ALL_PERMS, "children" => [], ], ], ], // Produtos / Inventário [ "scope" => "product", "description" => "Produtos", "bits" => Permission::ALL_PERMS, "children" => [ [ "scope" => "product-kit", "description" => "Kits de Produtos", "bits" => Permission::ALL_PERMS, "children" => [], ], [ "scope" => "product-movement", "description" => "Movimentação de Produtos", "bits" => Permission::ALL_PERMS, "children" => [], ], [ "scope" => "product-order", "description" => "Pedidos de Produtos", "bits" => Permission::ALL_PERMS, "children" => [ [ "scope" => "product-order-item", "description" => "Itens de Pedido de Produtos", "bits" => Permission::ALL_PERMS, "children" => [], ], ], ], ], ], [ "scope" => "franchisor-inventory", "description" => "Estoque (Franqueadora)", "bits" => Permission::ALL_PERMS, "children" => [], ], [ "scope" => "franchisee-inventory", "description" => "Estoque (Franqueado)", "bits" => Permission::ALL_PERMS, "children" => [], ], // Fornecedores / Pagamentos [ "scope" => "supplier", "description" => "Fornecedores", "bits" => Permission::ALL_PERMS, "children" => [], ], [ "scope" => "payment-method", "description" => "Formas de Pagamento", "bits" => Permission::ALL_PERMS, "children" => [], ], // Financeiro [ "scope" => "financial", "description" => "Financeiro", "bits" => Permission::MENU | Permission::VIEW, "children" => [ [ "scope" => "financial-account-payable", "description" => "Contas a Pagar", "bits" => Permission::ALL_PERMS, "children" => [], ], [ "scope" => "financial-account-receive", "description" => "Contas a Receber", "bits" => Permission::ALL_PERMS, "children" => [], ], [ "scope" => "financial-invoice", "description" => "Notas Fiscais", "bits" => Permission::ALL_PERMS, "children" => [], ], [ "scope" => "financial-plan-account", "description" => "Plano de Contas", "bits" => Permission::ALL_PERMS, "children" => [], ], ], ], // Tesouraria [ "scope" => "treasury", "description" => "Tesouraria", "bits" => Permission::MENU | Permission::VIEW, "children" => [ [ "scope" => "treasury-account", "description" => "Contas de Tesouraria", "bits" => Permission::ALL_PERMS, "children" => [], ], [ "scope" => "treasury-imports", "description" => "Importações de Tesouraria", "bits" => Permission::ALL_PERMS, "children" => [ [ "scope" => "treasury-import-line", "description" => "Linhas de Importação", "bits" => Permission::ALL_PERMS, "children" => [], ], ], ], [ "scope" => "treasury-launch", "description" => "Lançamentos de Tesouraria", "bits" => Permission::ALL_PERMS, "children" => [], ], ], ], // Integrações [ "scope" => "integrations", "description" => "Integrações", "bits" => Permission::ALL_PERMS, "children" => [ [ "scope" => "integration-variable", "description" => "Variáveis de Integração", "bits" => Permission::ALL_PERMS, "children" => [], ], ], ], // Feriados [ "scope" => "holiday", "description" => "Feriados", "bits" => Permission::ALL_PERMS, "children" => [ [ "scope" => "base-holiday", "description" => "Feriados Base", "bits" => Permission::ALL_PERMS, "children" => [], ], ], ], // TBR [ "scope" => "tbr", "description" => "TBR", "bits" => Permission::ALL_PERMS, "children" => [ [ "scope" => "tbr-calculation", "description" => "Cálculo de TBR", "bits" => Permission::VIEW | Permission::ADD, "children" => [], ], [ "scope" => "inhabitant-classification", "description" => "Classificações de Habitantes", "bits" => Permission::ALL_PERMS, "children" => [], ], ], ], // Configurações [ "scope" => "config", "description" => "Configurações", "bits" => Permission::MENU | Permission::VIEW, "children" => [ [ "scope" => "config.user", "description" => "Usuários", "bits" => Permission::CRUD, "children" => [], ], [ "scope" => "config.user-type", "description" => "Tipos de Usuário", "bits" => Permission::CRUD, "children" => [], ], [ "scope" => "config.permission", "description" => "Permissões", "bits" => Permission::CRUD, "children" => [], ], [ "scope" => "config.city", "description" => "Cidades", "bits" => Permission::CRUD, "children" => [], ], [ "scope" => "config.country", "description" => "Países", "bits" => Permission::CRUD, "children" => [], ], [ "scope" => "config.state", "description" => "Estados", "bits" => Permission::CRUD, "children" => [], ], ], ], // Unidade — escopos adicionais usados em subrotas de unit [ "scope" => "unit-user", "description" => "Usuários da Unidade", "bits" => Permission::ALL_PERMS, "children" => [], ], ]; $this->createPermissionsAndChildren(permissions: $permissions); } /** * Recursively creates or updates permissions and handles nesting. */ private function createPermissionsAndChildren( array $permissions, ?Permission $parent = null, ): void { foreach ($permissions as $permissionData) { $children = $permissionData["children"]; unset($permissionData["children"]); $permissionNode = Permission::updateOrCreate( ["scope" => $permissionData["scope"]], $permissionData, ); if ($parent) { $parent->appendNode($permissionNode); } if (!empty($children)) { $this->createPermissionsAndChildren( permissions: $children, parent: $permissionNode, ); } } } }