diff --git a/app/Http/Controllers/CondominioController.php b/app/Http/Controllers/CondominioController.php
index 2cda2fa..79ddaf7 100644
--- a/app/Http/Controllers/CondominioController.php
+++ b/app/Http/Controllers/CondominioController.php
@@ -23,4 +23,6 @@ class CondominioController extends Controller
{
abort(403);
}
+
+
}
diff --git a/app/Http/Controllers/Utenti.php b/app/Http/Controllers/Utenti.php
index e0cd330..24d4328 100644
--- a/app/Http/Controllers/Utenti.php
+++ b/app/Http/Controllers/Utenti.php
@@ -4,23 +4,25 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
-use Junges\ACL\Models\Group;
-use Junges\ACL\Models\Permission;
+// use Junges\ACL\Models\Group;
+// use Junges\ACL\Models\Permission;
+use Spatie\Permission\Models\Role;
+use Spatie\Permission\Models\Permission;
class Utenti extends Controller
{
//
- public function nuovoGruppo()
+ /* public function nuovoGruppo()
{
- return view('vendor.junges.form_addGroup',['gruppi'=>Utenti::getGruppi()]);
+ return view('vendor.junges.form_addGroup',['gruppi'=>Utenti::getGruppi()]);
}
-
+
public function saveNuovoGruppo(Request $request)
{
$group=Group::create(['name' => $request['gruppo'],'description'=>$request['descrizione']]);
return view('vendor.junges.form_addGroup',['gruppi'=>Utenti::getGruppi()]);
}
-
+
public function nuovoPermesso()
{
return view('vendor.junges.form_addPermission',['permessi'=>Utenti::getPermessi()]);
@@ -30,17 +32,17 @@ class Utenti extends Controller
$group=Permission::create(['name' => $request['permesso'],'description'=>$request['descrizione']]);
return view('vendor.junges.form_addPermission',['permessi'=>Utenti::getPermessi()]);
}
-
+
public function getPermessi()
{
return DB::table('permissions')->orderBy('name')->get();
}
-
+
public function getGruppi()
{
return DB::table('groups')->orderBy('name')->get();
}
-
+
public function vw_assignToGroup()
{
return view('vendor.junges.assignPermissionToGroup',[
@@ -48,7 +50,7 @@ class Utenti extends Controller
'gruppi'=>Utenti::getGruppi(),
]);
}
-
+
public function assignPermissionToGroup(Request $request)
{
$group=Group::findByName($request['gruppo']);
@@ -57,5 +59,16 @@ class Utenti extends Controller
'permessi'=>Utenti::getPermessi(),
'gruppi'=>Utenti::getGruppi(),
]);
+ }*/
+
+ public function createRole($ruolo)
+ {
+ $role=Role::create(['name'=>$ruolo]);
+ return json_encode(Role::all()->pluck('name'));
+ }
+
+ function createPermission($permesso){
+ $permission=Permission::create(['name'=>$permesso]);
+ return json_encode(Permission::all()->pluck('name'));
}
}
diff --git a/app/Models/User.php b/app/Models/User.php
index 416ade0..e617467 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -4,19 +4,20 @@ namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
-use Illuminate\Database\Eloquent\SoftDeletes;
+// use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\DB;
use Laravel\Sanctum\HasApiTokens;
- //use LdapRecord\Laravel\Auth\Authenticatable;
use LdapRecord\Laravel\Auth\AuthenticatesWithLdap;
-use Junges\ACL\Concerns\HasGroups;
+use Illuminate\Contracts\Auth\Access\Authorizable ;
+use Spatie\Permission\Traits\HasRole;
+
class User extends Authenticatable
{
- use HasApiTokens, HasFactory, Notifiable, AuthenticateswithLdap, HasGroups, SoftDeletes;
+ use HasApiTokens, HasFactory, Notifiable, AuthenticateswithLdap, HasRoles;
/**
* The attributes that are mass assignable.
@@ -27,6 +28,7 @@ class User extends Authenticatable
'name',
'email',
'password',
+ 'user_role',
];
/**
@@ -73,6 +75,6 @@ class User extends Authenticatable
return DB::table('users')->orderBy('name')->get();
}
-
+
}
diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php
index 22b77e6..c6daa99 100644
--- a/app/Providers/AuthServiceProvider.php
+++ b/app/Providers/AuthServiceProvider.php
@@ -26,5 +26,10 @@ class AuthServiceProvider extends ServiceProvider
$this->registerPolicies();
//
+ Gate::define('admin', function(User $user ){
+ return $user->isAdmin
+ ? Response::allow()
+ : Response::deny('E\'necessario essere amministratori per accedere a questa risorsa');
+ });
}
}
diff --git a/composer.json b/composer.json
index aaf55f8..cab09aa 100644
--- a/composer.json
+++ b/composer.json
@@ -20,12 +20,12 @@
"laravel/tinker": "^2.5",
"laravel/ui": "^3.4",
"laraveldaily/laravel-charts": "^0.1.29",
- "mateusjunges/laravel-acl": "^4.2",
"rap2hpoutre/fast-excel": "^3.2",
"secondtruth/startmin": "^1.1",
"sfneal/view-export": "^2.10",
"snapappointments/bootstrap-select": "^1.13",
"spatie/laravel-backup": "^7.0",
+ "spatie/laravel-permission": "^5.10",
"webklex/laravel-imap": "^2.4"
},
"require-dev" : {
diff --git a/composer.lock b/composer.lock
index 279f2ff..9103649 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "54f5d58038210c158e2f6aa9ddac0439",
+ "content-hash": "c69944f6249d2fefae8ae862a932e01e",
"packages": [
{
"name": "asm89/stack-cors",
@@ -1133,59 +1133,6 @@
},
"time": "2022-09-18T07:06:19+00:00"
},
- {
- "name": "facade/ignition-contracts",
- "version": "1.0.2",
- "source": {
- "type": "git",
- "url": "https://github.com/facade/ignition-contracts.git",
- "reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/facade/ignition-contracts/zipball/3c921a1cdba35b68a7f0ccffc6dffc1995b18267",
- "reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267",
- "shasum": ""
- },
- "require": {
- "php": "^7.3|^8.0"
- },
- "require-dev": {
- "friendsofphp/php-cs-fixer": "^v2.15.8",
- "phpunit/phpunit": "^9.3.11",
- "vimeo/psalm": "^3.17.1"
- },
- "type": "library",
- "autoload": {
- "psr-4": {
- "Facade\\IgnitionContracts\\": "src"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Freek Van der Herten",
- "email": "freek@spatie.be",
- "homepage": "https://flareapp.io",
- "role": "Developer"
- }
- ],
- "description": "Solution contracts for Ignition",
- "homepage": "https://github.com/facade/ignition-contracts",
- "keywords": [
- "contracts",
- "flare",
- "ignition"
- ],
- "support": {
- "issues": "https://github.com/facade/ignition-contracts/issues",
- "source": "https://github.com/facade/ignition-contracts/tree/1.0.2"
- },
- "time": "2020-10-16T08:27:54+00:00"
- },
{
"name": "fruitcake/laravel-cors",
"version": "v2.2.0",
@@ -2933,89 +2880,6 @@
},
"time": "2022-08-18T16:18:26+00:00"
},
- {
- "name": "mateusjunges/laravel-acl",
- "version": "v4.2.1",
- "source": {
- "type": "git",
- "url": "https://github.com/mateusjunges/laravel-acl.git",
- "reference": "d4d41b897002218e11d6826e5b021ff4935ec19d"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/mateusjunges/laravel-acl/zipball/d4d41b897002218e11d6826e5b021ff4935ec19d",
- "reference": "d4d41b897002218e11d6826e5b021ff4935ec19d",
- "shasum": ""
- },
- "require": {
- "facade/ignition-contracts": "^1.0",
- "illuminate/auth": "^8.0|^9.0",
- "illuminate/container": "^8.0|^9.0",
- "illuminate/database": "^8.0|^9.0",
- "illuminate/support": "^8.0|^9.0",
- "php": "^7.4|^8.0"
- },
- "require-dev": {
- "friendsofphp/php-cs-fixer": "^3.4",
- "orchestra/testbench": "^6.0|^7.0",
- "phpunit/phpunit": "^9.4",
- "predis/predis": "^1.1"
- },
- "suggest": {
- "facade/igntion": "Needed to be able to use the ignition solutions for laravel-acl"
- },
- "type": "laravel-package",
- "extra": {
- "laravel": {
- "providers": [
- "Junges\\ACL\\Providers\\ACLServiceProvider",
- "Junges\\ACL\\Providers\\ACLAuthServiceProvider",
- "Junges\\ACL\\Providers\\ACLEventsServiceProvider"
- ]
- }
- },
- "autoload": {
- "files": [
- "src/helpers.php"
- ],
- "psr-4": {
- "Junges\\ACL\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Mateus Junges",
- "email": "mateus@junges.dev",
- "homepage": "https://twitter.com/mateusjungess",
- "role": "Backend Software Engineer"
- }
- ],
- "description": "This package provides a complete Access Control List management",
- "homepage": "https://github.com/mateusjunges/laravel-acl",
- "keywords": [
- "access-control-list",
- "acl",
- "junges",
- "laravel",
- "permissions",
- "security"
- ],
- "support": {
- "issues": "https://github.com/mateusjunges/laravel-acl/issues",
- "source": "https://github.com/mateusjunges/laravel-acl"
- },
- "funding": [
- {
- "url": "https://github.com/mateusjunges",
- "type": "github"
- }
- ],
- "time": "2022-12-15T02:50:22+00:00"
- },
{
"name": "monolog/monolog",
"version": "2.9.1",
@@ -5552,6 +5416,88 @@
],
"time": "2022-06-28T14:29:26+00:00"
},
+ {
+ "name": "spatie/laravel-permission",
+ "version": "5.10.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/spatie/laravel-permission.git",
+ "reference": "d08b3ffc5870cce4a47a39f22174947b33c191ae"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/spatie/laravel-permission/zipball/d08b3ffc5870cce4a47a39f22174947b33c191ae",
+ "reference": "d08b3ffc5870cce4a47a39f22174947b33c191ae",
+ "shasum": ""
+ },
+ "require": {
+ "illuminate/auth": "^7.0|^8.0|^9.0|^10.0",
+ "illuminate/container": "^7.0|^8.0|^9.0|^10.0",
+ "illuminate/contracts": "^7.0|^8.0|^9.0|^10.0",
+ "illuminate/database": "^7.0|^8.0|^9.0|^10.0",
+ "php": "^7.3|^8.0"
+ },
+ "require-dev": {
+ "orchestra/testbench": "^5.0|^6.0|^7.0|^8.0",
+ "phpunit/phpunit": "^9.4",
+ "predis/predis": "^1.1"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "5.x-dev",
+ "dev-master": "5.x-dev"
+ },
+ "laravel": {
+ "providers": [
+ "Spatie\\Permission\\PermissionServiceProvider"
+ ]
+ }
+ },
+ "autoload": {
+ "files": [
+ "src/helpers.php"
+ ],
+ "psr-4": {
+ "Spatie\\Permission\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Freek Van der Herten",
+ "email": "freek@spatie.be",
+ "homepage": "https://spatie.be",
+ "role": "Developer"
+ }
+ ],
+ "description": "Permission handling for Laravel 6.0 and up",
+ "homepage": "https://github.com/spatie/laravel-permission",
+ "keywords": [
+ "acl",
+ "laravel",
+ "permission",
+ "permissions",
+ "rbac",
+ "roles",
+ "security",
+ "spatie"
+ ],
+ "support": {
+ "issues": "https://github.com/spatie/laravel-permission/issues",
+ "source": "https://github.com/spatie/laravel-permission/tree/5.10.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/spatie",
+ "type": "github"
+ }
+ ],
+ "time": "2023-04-12T17:08:32+00:00"
+ },
{
"name": "spatie/laravel-signal-aware-command",
"version": "1.3.0",
@@ -8631,6 +8577,59 @@
},
"time": "2023-01-26T12:34:59+00:00"
},
+ {
+ "name": "facade/ignition-contracts",
+ "version": "1.0.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/facade/ignition-contracts.git",
+ "reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/facade/ignition-contracts/zipball/3c921a1cdba35b68a7f0ccffc6dffc1995b18267",
+ "reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.3|^8.0"
+ },
+ "require-dev": {
+ "friendsofphp/php-cs-fixer": "^v2.15.8",
+ "phpunit/phpunit": "^9.3.11",
+ "vimeo/psalm": "^3.17.1"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Facade\\IgnitionContracts\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Freek Van der Herten",
+ "email": "freek@spatie.be",
+ "homepage": "https://flareapp.io",
+ "role": "Developer"
+ }
+ ],
+ "description": "Solution contracts for Ignition",
+ "homepage": "https://github.com/facade/ignition-contracts",
+ "keywords": [
+ "contracts",
+ "flare",
+ "ignition"
+ ],
+ "support": {
+ "issues": "https://github.com/facade/ignition-contracts/issues",
+ "source": "https://github.com/facade/ignition-contracts/tree/1.0.2"
+ },
+ "time": "2020-10-16T08:27:54+00:00"
+ },
{
"name": "fakerphp/faker",
"version": "v1.21.0",
@@ -10734,5 +10733,5 @@
"php": "^7.3|^8.0"
},
"platform-dev": [],
- "plugin-api-version": "2.2.0"
+ "plugin-api-version": "2.3.0"
}
diff --git a/config/app.php b/config/app.php
index 4a7a159..d60981b 100644
--- a/config/app.php
+++ b/config/app.php
@@ -161,6 +161,7 @@ return [
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
+ Spatie\Permission\PermissionServiceProvider::class,
/*
* Package Service Providers...
diff --git a/config/permission.php b/config/permission.php
new file mode 100644
index 0000000..5b6e184
--- /dev/null
+++ b/config/permission.php
@@ -0,0 +1,161 @@
+ [
+
+ /*
+ * When using the "HasPermissions" trait from this package, we need to know which
+ * Eloquent model should be used to retrieve your permissions. Of course, it
+ * is often just the "Permission" model but you may use whatever you like.
+ *
+ * The model you want to use as a Permission model needs to implement the
+ * `Spatie\Permission\Contracts\Permission` contract.
+ */
+
+ 'permission' => Spatie\Permission\Models\Permission::class,
+
+ /*
+ * When using the "HasRoles" trait from this package, we need to know which
+ * Eloquent model should be used to retrieve your roles. Of course, it
+ * is often just the "Role" model but you may use whatever you like.
+ *
+ * The model you want to use as a Role model needs to implement the
+ * `Spatie\Permission\Contracts\Role` contract.
+ */
+
+ 'role' => Spatie\Permission\Models\Role::class,
+
+ ],
+
+ 'table_names' => [
+
+ /*
+ * When using the "HasRoles" trait from this package, we need to know which
+ * table should be used to retrieve your roles. We have chosen a basic
+ * default value but you may easily change it to any table you like.
+ */
+
+ 'roles' => 'roles',
+
+ /*
+ * When using the "HasPermissions" trait from this package, we need to know which
+ * table should be used to retrieve your permissions. We have chosen a basic
+ * default value but you may easily change it to any table you like.
+ */
+
+ 'permissions' => 'permissions',
+
+ /*
+ * When using the "HasPermissions" trait from this package, we need to know which
+ * table should be used to retrieve your models permissions. We have chosen a
+ * basic default value but you may easily change it to any table you like.
+ */
+
+ 'model_has_permissions' => 'model_has_permissions',
+
+ /*
+ * When using the "HasRoles" trait from this package, we need to know which
+ * table should be used to retrieve your models roles. We have chosen a
+ * basic default value but you may easily change it to any table you like.
+ */
+
+ 'model_has_roles' => 'model_has_roles',
+
+ /*
+ * When using the "HasRoles" trait from this package, we need to know which
+ * table should be used to retrieve your roles permissions. We have chosen a
+ * basic default value but you may easily change it to any table you like.
+ */
+
+ 'role_has_permissions' => 'role_has_permissions',
+ ],
+
+ 'column_names' => [
+ /*
+ * Change this if you want to name the related pivots other than defaults
+ */
+ 'role_pivot_key' => null, //default 'role_id',
+ 'permission_pivot_key' => null, //default 'permission_id',
+
+ /*
+ * Change this if you want to name the related model primary key other than
+ * `model_id`.
+ *
+ * For example, this would be nice if your primary keys are all UUIDs. In
+ * that case, name this `model_uuid`.
+ */
+
+ 'model_morph_key' => 'model_id',
+
+ /*
+ * Change this if you want to use the teams feature and your related model's
+ * foreign key is other than `team_id`.
+ */
+
+ 'team_foreign_key' => 'team_id',
+ ],
+
+ /*
+ * When set to true, the method for checking permissions will be registered on the gate.
+ * Set this to false, if you want to implement custom logic for checking permissions.
+ */
+
+ 'register_permission_check_method' => true,
+
+ /*
+ * When set to true the package implements teams using the 'team_foreign_key'. If you want
+ * the migrations to register the 'team_foreign_key', you must set this to true
+ * before doing the migration. If you already did the migration then you must make a new
+ * migration to also add 'team_foreign_key' to 'roles', 'model_has_roles', and
+ * 'model_has_permissions'(view the latest version of package's migration file)
+ */
+
+ 'teams' => false,
+
+ /*
+ * When set to true, the required permission names are added to the exception
+ * message. This could be considered an information leak in some contexts, so
+ * the default setting is false here for optimum safety.
+ */
+
+ 'display_permission_in_exception' => false,
+
+ /*
+ * When set to true, the required role names are added to the exception
+ * message. This could be considered an information leak in some contexts, so
+ * the default setting is false here for optimum safety.
+ */
+
+ 'display_role_in_exception' => false,
+
+ /*
+ * By default wildcard permission lookups are disabled.
+ */
+
+ 'enable_wildcard_permission' => false,
+
+ 'cache' => [
+
+ /*
+ * By default all permissions are cached for 24 hours to speed up performance.
+ * When permissions or roles are updated the cache is flushed automatically.
+ */
+
+ 'expiration_time' => \DateInterval::createFromDateString('24 hours'),
+
+ /*
+ * The cache key used to store all permissions.
+ */
+
+ 'key' => 'spatie.permission.cache',
+
+ /*
+ * You may optionally indicate a specific cache driver to use for permission and
+ * role caching using any of the `store` drivers listed in the cache.php config
+ * file. Using 'default' here means to use the `default` set in cache.php.
+ */
+
+ 'store' => 'default',
+ ],
+];
diff --git a/database/migrations/2023_06_01_140555_create_permission_tables.php b/database/migrations/2023_06_01_140555_create_permission_tables.php
new file mode 100644
index 0000000..04c3278
--- /dev/null
+++ b/database/migrations/2023_06_01_140555_create_permission_tables.php
@@ -0,0 +1,141 @@
+bigIncrements('id'); // permission id
+ $table->string('name'); // For MySQL 8.0 use string('name', 125);
+ $table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
+ $table->timestamps();
+
+ $table->unique(['name', 'guard_name']);
+ });
+
+ Schema::create($tableNames['roles'], function (Blueprint $table) use ($teams, $columnNames) {
+ $table->bigIncrements('id'); // role id
+ if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
+ $table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
+ $table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
+ }
+ $table->string('name'); // For MySQL 8.0 use string('name', 125);
+ $table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
+ $table->timestamps();
+ if ($teams || config('permission.testing')) {
+ $table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
+ } else {
+ $table->unique(['name', 'guard_name']);
+ }
+ });
+
+ Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) {
+ $table->unsignedBigInteger(PermissionRegistrar::$pivotPermission);
+
+ $table->string('model_type');
+ $table->unsignedBigInteger($columnNames['model_morph_key']);
+ $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
+
+ $table->foreign(PermissionRegistrar::$pivotPermission)
+ ->references('id') // permission id
+ ->on($tableNames['permissions'])
+ ->onDelete('cascade');
+ if ($teams) {
+ $table->unsignedBigInteger($columnNames['team_foreign_key']);
+ $table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
+
+ $table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
+ 'model_has_permissions_permission_model_type_primary');
+ } else {
+ $table->primary([PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
+ 'model_has_permissions_permission_model_type_primary');
+ }
+
+ });
+
+ Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) {
+ $table->unsignedBigInteger(PermissionRegistrar::$pivotRole);
+
+ $table->string('model_type');
+ $table->unsignedBigInteger($columnNames['model_morph_key']);
+ $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
+
+ $table->foreign(PermissionRegistrar::$pivotRole)
+ ->references('id') // role id
+ ->on($tableNames['roles'])
+ ->onDelete('cascade');
+ if ($teams) {
+ $table->unsignedBigInteger($columnNames['team_foreign_key']);
+ $table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
+
+ $table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'],
+ 'model_has_roles_role_model_type_primary');
+ } else {
+ $table->primary([PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'],
+ 'model_has_roles_role_model_type_primary');
+ }
+ });
+
+ Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) {
+ $table->unsignedBigInteger(PermissionRegistrar::$pivotPermission);
+ $table->unsignedBigInteger(PermissionRegistrar::$pivotRole);
+
+ $table->foreign(PermissionRegistrar::$pivotPermission)
+ ->references('id') // permission id
+ ->on($tableNames['permissions'])
+ ->onDelete('cascade');
+
+ $table->foreign(PermissionRegistrar::$pivotRole)
+ ->references('id') // role id
+ ->on($tableNames['roles'])
+ ->onDelete('cascade');
+
+ $table->primary([PermissionRegistrar::$pivotPermission, PermissionRegistrar::$pivotRole], 'role_has_permissions_permission_id_role_id_primary');
+ });
+
+ app('cache')
+ ->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
+ ->forget(config('permission.cache.key'));
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ $tableNames = config('permission.table_names');
+
+ if (empty($tableNames)) {
+ throw new \Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
+ }
+
+ Schema::drop($tableNames['role_has_permissions']);
+ Schema::drop($tableNames['model_has_roles']);
+ Schema::drop($tableNames['model_has_permissions']);
+ Schema::drop($tableNames['roles']);
+ Schema::drop($tableNames['permissions']);
+ }
+}
diff --git a/resources/views/components/usermenu.blade.php b/resources/views/components/usermenu.blade.php
index 2ba37c6..a194c57 100644
--- a/resources/views/components/usermenu.blade.php
+++ b/resources/views/components/usermenu.blade.php
@@ -7,10 +7,15 @@
+
diff --git a/resources/views/vendor/junges/acl/_forms/groups/group.blade.php b/resources/views/vendor/junges/acl/_forms/groups/group.blade.php
deleted file mode 100644
index 9da1e1a..0000000
--- a/resources/views/vendor/junges/acl/_forms/groups/group.blade.php
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
-
-
- @if($errors->has('name'))
- {{ $errors->first('name') }}
- @endif
-
-
-
-
- @if($errors->has('slug'))
- {{ $errors->first('slug') }}
- @endif
-
-
-
-
- @if($errors->has('description'))
- {{ $errors->first('description') }}
- @endif
-
-
-
-
- @if($errors->has('permissions'))
- {{ $errors->first('permissions') }}
- @endif
-
\ No newline at end of file
diff --git a/resources/views/vendor/junges/acl/_forms/users/add-group.blade.php b/resources/views/vendor/junges/acl/_forms/users/add-group.blade.php
deleted file mode 100644
index d2ed386..0000000
--- a/resources/views/vendor/junges/acl/_forms/users/add-group.blade.php
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
-
- @if($errors->has('users'))
- {{ $errors->first('users') }}
- @endif
-
-
-
-
-
diff --git a/resources/views/vendor/junges/acl/_forms/users/add-permission.blade.php b/resources/views/vendor/junges/acl/_forms/users/add-permission.blade.php
deleted file mode 100644
index 7339274..0000000
--- a/resources/views/vendor/junges/acl/_forms/users/add-permission.blade.php
+++ /dev/null
@@ -1,59 +0,0 @@
-@csrf
-
-
-
- @if($errors->has('user'))
- {{ $errors->first('user') }}
- @endif
-
-
-
-
- @if($errors->has('permissions'))
-
{{ $errors->first('permissions') }}
-@endif
\ No newline at end of file
diff --git a/resources/views/vendor/junges/assignPermissionToGroup.blade.php b/resources/views/vendor/junges/assignPermissionToGroup.blade.php
deleted file mode 100644
index ad6593e..0000000
--- a/resources/views/vendor/junges/assignPermissionToGroup.blade.php
+++ /dev/null
@@ -1,44 +0,0 @@
-@extends('admin')
-@section('content')
-
-
-
-
-
-
- Assegnazione dei permessi ai gruppi
-
-
-
-
-
-
- @endsection
\ No newline at end of file
diff --git a/resources/views/vendor/junges/form_addGroup.blade.php b/resources/views/vendor/junges/form_addGroup.blade.php
deleted file mode 100644
index 864adec..0000000
--- a/resources/views/vendor/junges/form_addGroup.blade.php
+++ /dev/null
@@ -1,67 +0,0 @@
-@extends('admin')
-@section('content')
-
-
-
-
-
-
- Inserimento dei gruppi
-
-
-
-
-
- Gruppi inseriti
-
-
-
-
-
-
- Gruppo |
- Descrizione |
-
-
-
- @foreach($gruppi as $gruppo)
-
- {{ $gruppo->name ?? ''; }} |
- {{ $gruppo->description ?? ''; }} |
-
- @endforeach
-
-
-
-
-
-
-@endsection
-@section('script')
-
-@endsection
\ No newline at end of file
diff --git a/resources/views/vendor/junges/form_addPermission.blade.php b/resources/views/vendor/junges/form_addPermission.blade.php
deleted file mode 100644
index ba65710..0000000
--- a/resources/views/vendor/junges/form_addPermission.blade.php
+++ /dev/null
@@ -1,67 +0,0 @@
-@extends('admin')
-@section('content')
-
-
-
-
-
-
- Inserimento dei permessi
-
-
-
-
-
- Permessi inseriti
-
-
-
-
-
-
- Permesso |
- Descrizione |
-
-
-
- @foreach($permessi as $permesso)
-
- {{ $permesso->name ?? ''; }} |
- {{ $permesso->description ?? ''; }} |
-
- @endforeach
-
-
-
-
-
-
-@endsection
-@section('script')
-
-@endsection
\ No newline at end of file
diff --git a/routes/admin.php b/routes/admin.php
index b0bd1bf..19c3b6b 100644
--- a/routes/admin.php
+++ b/routes/admin.php
@@ -108,9 +108,9 @@ Route::get('/', [MovimentiController::class,'dashboard']);
Route::post('contatti/addOther', [AnagraficaController::class, 'saveOtherContact']);
// GRUPPI E PERMESSI
- Route::get('group/new', [Utenti::class, 'nuovoGruppo']);
+ Route::get('role/new/{ruolo}', [Utenti::class, 'createRole']);
Route::post('group/new', [Utenti::class, 'saveNuovoGruppo']);
- Route::get('permesso/new', [Utenti::class, 'nuovoPermesso']);
+ Route::get('permesso/new/{permesso}', [Utenti::class, 'createPermission']);
Route::post('permesso/new', [Utenti::class, 'saveNuovoPermesso']);
Route::get('permesso/assign', [Utenti::class, 'vw_assignToGroup']);
Route::post('permesso/assign', [Utenti::class, 'assignPermissionToGroup']);
@@ -132,5 +132,5 @@ Route::get('/', [MovimentiController::class,'dashboard']);
Route::post('test/fullcalendar', [FullCalenderController::class, 'ajax']);
Route::get('test/condominio',[CondominioController::class,'testPdf']);
Route::get('test/err403',[CondominioController::class,'err403']);
-
+ Route::get('test/user_role',[CondominioController::class,'user_role']);