|
@@ -5,6 +5,7 @@
|
|
|
use App\DataTransferObjects\PermissionDto;
|
|
use App\DataTransferObjects\PermissionDto;
|
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Database\Seeder;
|
|
|
use App\Services\PermissionService;
|
|
use App\Services\PermissionService;
|
|
|
|
|
+
|
|
|
class PermissionSeeder extends Seeder
|
|
class PermissionSeeder extends Seeder
|
|
|
{
|
|
{
|
|
|
public function __construct(
|
|
public function __construct(
|
|
@@ -16,14 +17,14 @@ public function run(): void
|
|
|
{
|
|
{
|
|
|
// Criação de Permissões
|
|
// Criação de Permissões
|
|
|
/*
|
|
/*
|
|
|
- visualizar = 1
|
|
|
|
|
- adicionar = 2
|
|
|
|
|
- editar = 4
|
|
|
|
|
- deletar = 8
|
|
|
|
|
- imprimir = 16
|
|
|
|
|
- exportar = 32
|
|
|
|
|
- importar = 64
|
|
|
|
|
- limitar = 128
|
|
|
|
|
|
|
+ view = 1
|
|
|
|
|
+ add = 2
|
|
|
|
|
+ edit = 4
|
|
|
|
|
+ delete = 8
|
|
|
|
|
+ print = 16
|
|
|
|
|
+ export = 32
|
|
|
|
|
+ import = 64
|
|
|
|
|
+ limit = 128
|
|
|
menu = 256
|
|
menu = 256
|
|
|
|
|
|
|
|
para cada cada bit selecionado se faz a soma dos valores.
|
|
para cada cada bit selecionado se faz a soma dos valores.
|
|
@@ -36,10 +37,23 @@ public function run(): void
|
|
|
'children' => []
|
|
'children' => []
|
|
|
],
|
|
],
|
|
|
[
|
|
[
|
|
|
- 'scope' => 'usuarios',
|
|
|
|
|
- 'description' => 'Usuários',
|
|
|
|
|
|
|
+ 'scope' => 'config',
|
|
|
|
|
+ 'description' => 'Configurações',
|
|
|
'bits' => 271,
|
|
'bits' => 271,
|
|
|
- 'children' => []
|
|
|
|
|
|
|
+ 'children' => [
|
|
|
|
|
+ [
|
|
|
|
|
+ 'scope' => 'config.user',
|
|
|
|
|
+ 'description' => 'Configurações de Usuários',
|
|
|
|
|
+ 'bits' => 271,
|
|
|
|
|
+ 'children' => []
|
|
|
|
|
+ ],
|
|
|
|
|
+ [
|
|
|
|
|
+ 'scope' => 'config.permission',
|
|
|
|
|
+ 'description' => 'Configurações de Permissões',
|
|
|
|
|
+ 'bits' => 271,
|
|
|
|
|
+ 'children' => []
|
|
|
|
|
+ ]
|
|
|
|
|
+ ],
|
|
|
],
|
|
],
|
|
|
];
|
|
];
|
|
|
|
|
|
|
@@ -49,9 +63,9 @@ public function run(): void
|
|
|
private function createPermissionsAndChildren(array $permissions)
|
|
private function createPermissionsAndChildren(array $permissions)
|
|
|
{
|
|
{
|
|
|
foreach ($permissions as $permission) {
|
|
foreach ($permissions as $permission) {
|
|
|
- $this->permissionService->store(PermissionDto::fromArray($permission));
|
|
|
|
|
|
|
+ $this->permissionService->store(PermissionDto::fromArray((array) $permission));
|
|
|
|
|
|
|
|
- if (isset($permission['children'])) {
|
|
|
|
|
|
|
+ if (!empty($permission['children'])) {
|
|
|
$this->createPermissionsAndChildren($permission['children']);
|
|
$this->createPermissionsAndChildren($permission['children']);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|