Skip to content

Commit

Permalink
Quitar permisos de manejo de permisos del rol ppal de admin de usuari…
Browse files Browse the repository at this point in the history
…os y roles
  • Loading branch information
Fernando Pintabona committed May 14, 2024
1 parent 4a5f2f8 commit 0123863
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 41 deletions.
23 changes: 15 additions & 8 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/AdminPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Illuminate\Support\Facades\Auth;
use FefoP\AdminPanel\Models\Permission;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Auth\Access\AuthorizationException;

class AdminPanel extends Controller
{
Expand Down
64 changes: 32 additions & 32 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,10 @@ protected function create_roles_and_permissions($user)

$roles = [
[ 'name' => 'administrador' ],
[ 'name' => '(adminpanel) administrar usuarios y permisos' ],
[ 'name' => '(adminpanel) administrar usuarios y roles' ],
];

$permissions = [
[
'name' => 'adminpanel.usuario.administrar',
'guard_name' => 'web',
],
[
'name' => 'adminpanel.usuario.crear',
'guard_name' => 'web',
Expand All @@ -253,10 +249,6 @@ protected function create_roles_and_permissions($user)
'name' => 'adminpanel.usuario.borrar',
'guard_name' => 'web',
],
[
'name' => 'adminpanel.rol.administrar',
'guard_name' => 'web',
],
[
'name' => 'adminpanel.rol.crear',
'guard_name' => 'web',
Expand All @@ -273,26 +265,34 @@ protected function create_roles_and_permissions($user)
'name' => 'adminpanel.rol.borrar',
'guard_name' => 'web',
],
[
'name' => 'adminpanel.permiso.administrar',
'guard_name' => 'web',
],
[
'name' => 'adminpanel.permiso.crear',
'guard_name' => 'web',
],
[
'name' => 'adminpanel.permiso.ver',
'guard_name' => 'web',
],
[
'name' => 'adminpanel.permiso.editar',
'guard_name' => 'web',
],
[
'name' => 'adminpanel.permiso.borrar',
'guard_name' => 'web',
],
//[
// 'name' => 'adminpanel.usuario.administrar',
// 'guard_name' => 'web',
//],
//[
// 'name' => 'adminpanel.rol.administrar',
// 'guard_name' => 'web',
//],
//[
// 'name' => 'adminpanel.permiso.administrar',
// 'guard_name' => 'web',
//],
//[
// 'name' => 'adminpanel.permiso.crear',
// 'guard_name' => 'web',
//],
//[
// 'name' => 'adminpanel.permiso.editar',
// 'guard_name' => 'web',
//],
//[
// 'name' => 'adminpanel.permiso.borrar',
// 'guard_name' => 'web',
//],
];

foreach ( $roles as $role ) {
Expand All @@ -302,15 +302,15 @@ protected function create_roles_and_permissions($user)
}

foreach ( $permissions as $permission ) {
if ( !Permission::where('name', $permission['name'])->first() ) {
if ( !Permission::where('name', $permission[ 'name' ])->first() ) {
Permission::create($permission);
}
}

// Asignar permisos de manejo de usuarios a rol "(adminpanel) administrar usuarios y permisos"
// Asignar permisos de manejo de usuarios a rol "(adminpanel) administrar usuarios y roles"
$role = Role::latest()->first();
foreach ( $permissions as $permission ) {
if (! Str::of($permission["name"])->endsWith('.administrar')) {
if ( !Str::of($permission[ "name" ])->endsWith('.administrar') ) {
$role->givePermissionTo($permission[ 'name' ]);
}
}
Expand All @@ -320,14 +320,14 @@ protected function create_roles_and_permissions($user)
$role = Role::first();

foreach ( Permission::all() as $permission ) {
if (! Str::of($permission["name"])->startsWith('adminpanel.')) {
$role->givePermissionTo($permission['name']);
if ( !Str::of($permission[ "name" ])->startsWith('adminpanel.') ) {
$role->givePermissionTo($permission[ 'name' ]);
}
}

foreach ( $permissions as $permission ) {
if (Str::of($permission["name"])->endsWith('.ver')) {
$role->givePermissionTo($permission['name']);
if ( Str::of($permission[ "name" ])->endsWith('.ver') ) {
$role->givePermissionTo($permission[ 'name' ]);
}
}

Expand Down

0 comments on commit 0123863

Please sign in to comment.