"dashboard", "description" => "Dashboard", "bits" => Permission::ALL_PERMS, "children" => [], ], [ "scope" => "franchisor_franchisee", "description" => "Franqueados", "bits" => Permission::ALL_PERMS, "children" => [], ], // Pacotes / Aulas [ "scope" => "franchisor_packages", "description" => "Pacotes (Franqueadora)", "bits" => Permission::MENU | Permission::VIEW | Permission::ADD | Permission::EDIT, "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" => "franchisor_support", "description" => "Chamados 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" => "franchisor_products", "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" => "franchisor_financial", "description" => "Financeiro", "bits" => Permission::MENU | Permission::VIEW | Permission::ADD | Permission::EDIT, "children" => [], ], // Feriados [ "scope" => "holiday", "description" => "Feriados", "bits" => Permission::ALL_PERMS, "children" => [ [ "scope" => "base-holiday", "description" => "Feriados Base", "bits" => Permission::ALL_PERMS, "children" => [], ], ], ], // TBR [ "scope" => "franchisor_tbr", "description" => "TBR", "bits" => Permission::MENU | Permission::VIEW | Permission::ADD | Permission::EDIT, "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, ); } } } }