installato laravel-permission e rimosso junge/laravel-acl

This commit is contained in:
Amministratore 2023-06-01 16:57:39 +02:00
parent 8fc2b6ae83
commit ce5527ecde
17 changed files with 486 additions and 523 deletions

View File

@ -23,4 +23,6 @@ class CondominioController extends Controller
{
abort(403);
}
}

View File

@ -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'));
}
}

View File

@ -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();
}
}

View File

@ -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');
});
}
}

View File

@ -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" : {

275
composer.lock generated
View File

@ -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"
}

View File

@ -161,6 +161,7 @@ return [
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
Spatie\Permission\PermissionServiceProvider::class,
/*
* Package Service Providers...

161
config/permission.php Normal file
View File

@ -0,0 +1,161 @@
<?php
return [
'models' => [
/*
* 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',
],
];

View File

@ -0,0 +1,141 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Spatie\Permission\PermissionRegistrar;
class CreatePermissionTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$tableNames = config('permission.table_names');
$columnNames = config('permission.column_names');
$teams = config('permission.teams');
if (empty($tableNames)) {
throw new \Exception('Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
}
if ($teams && empty($columnNames['team_foreign_key'] ?? null)) {
throw new \Exception('Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
}
Schema::create($tableNames['permissions'], function (Blueprint $table) {
$table->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']);
}
}

View File

@ -7,10 +7,15 @@
<ul class="dropdown-menu dropdown-user">
<li><a href="#"><i class="fa fa-user fa-fw"></i> Profilo utente</a></li>
<li><a href="#"><i class="fa fa-gear fa-fw"></i> Impostazioni</a></li>
<li class="divider"></li>
<li><a href="#"><i class="fa fa-gear fa-fw"></i> Gestisci Utenti</a></li>
<li class="divider"></li>
<li><a href="https://github.com/fbarachino/bubofamily/issues/new/choose" target="new"><i class="fa fa-bug fa-fw"></i> Segnala un bug</a></li>
<li class="divider"></li>
<li><a href="{{ route('logout'); }}"><i class="fa fa-sign-out fa-fw"></i>
Logout</a></li>
</ul></li>
<!-- https://spatie.be/docs/laravel-permission/v5/basic-usage/new-app -->
<!-- /USERMENU -->

View File

@ -1,73 +0,0 @@
<input type="hidden" value="{{ csrf_token() }}" name="_token" id="_token">
<div class="form-group">
<label for="group-name">Nome:</label>
<input type="text"
id="group-name"
minlength="3"
name="name"
placeholder="Informe o nome do novo grupo"
value="{{ isset($group) ? $group->name : old('name') }}"
class="form-control">
@if($errors->has('name'))
<span class="text-danger">{{ $errors->first('name') }}</span>
@endif
</div>
<div class="form-group">
<label for="group-slug">Slug do grupo:</label>
<input type="text"
id="group-slug"
minlength="3"
name="slug"
placeholder="Informe o nome do novo grupo"
value="{{ isset($group) ? $group->slug : old('slug') }}"
class="form-control">
@if($errors->has('slug'))
<span class="text-danger">{{ $errors->first('slug') }}</span>
@endif
</div>
<label for="group-description">Descrição:</label>
<div class="form-group">
<textarea name="description"
id="group-description"
placeholder="Informe a descrição deste grupo"
minlength="5"
class="form-control"
cols="30" rows="10">{{ isset($group) ? $group->description : old('description') }}</textarea>
@if($errors->has('description'))
<span class="text-danger">{{ $errors->first('description') }}</span>
@endif
</div>
<div class="form-group">
<label for="group-permissions">Permissões:</label>
<select name="permissions[]"
style="width: 100%"
multiple
id="group-permissions"
class="form-control">
@if(isset($group))
@foreach($permissions as $permission)
<option value="{{ $permission->id }}"
{{ ($group->hasPermission($permission->id) ? 'selected' : '') }}
@if(old('$permissions') != null)
{{ (in_array($permission->id, old('permissions')) ? 'selected' : '') }}
@endif
>
{{ $permission->name }}
</option>
@endforeach
@else
@foreach($permissions as $permission)
<option value="{{ $permission->id }}"
@if(old('permissions') != null)
{{ in_array($permission->id, old('permissions')) ? 'selected' : '' }}
@endif
>
{{ $permission->name }}
</option>
@endforeach
@endif
</select>
@if($errors->has('permissions'))
<span class="text-danger">{{ $errors->first('permissions') }}</span>
@endif
</div>

View File

@ -1,56 +0,0 @@
<div class="form-group">
<label for="users">Selecione o usuário</label>
<select name="user"
id="users"
class="form-control">
@if(isset($user))
@foreach($users as $u)
<option value="{{ $u->id }}"
@if(($u->id == $user->id) || ($u->id == old('user')))
selected
@endif
>
{{ $u->name }}
</option>
@endforeach
@else
@foreach($users as $u)
<option value="{{ $u->id }}" {{ $u->id == old('user') ? 'selected' : '' }}>
{{ $u->name }}
</option>
@endforeach
@endif
</select>
@if($errors->has('users'))
<small class="text-danger">{{ $errors->first('users') }}</small>
@endif
</div>
<div class="form-group">
<label for="groups">Selecione os grupos:</label>
<select name="groups[]"
multiple="multiple"
id="groups" class="form-control">
@if(isset($user))
@foreach($groups as $g)
<option value="{{ $g->id }}"
{{ $user->hasGroup($g) ? 'selected' : '' }}
@if(old('groups') != null)
{{ (in_array($g->id, old('groups')) ? 'selected' : '') }}
@endif
>
{{ $g->name }}
</option>
@endforeach
@else
@foreach($groups as $g)
<option value="{{ $g->id }}"
@if(old('groups') != null)
{{ in_array($g->id, old('groups')) ? 'selected' : '' }}
@endif
>
{{ $g->name }}
</option>
@endforeach
@endif
</select>
</div>

View File

@ -1,59 +0,0 @@
@csrf
<div class="form-group">
<label for="user">Selecione o usuário:</label>
<select name="user"
id="user"
class="form-control">
@if(isset($user))
@foreach($users as $u)
<option value="{{ $user->id }}"
@if(($u->id == $user->id) || ($u->id == old('user')))
selected
@endif
>
{{ $u->name }}</option>
@endforeach
@else
@foreach($users as $u)
<option value="{{ $u->id }}" {{ $u->id == old('user') ? 'selected' : '' }}>
{{ $u->name }}</option>
@endforeach
@endif
</select>
@if($errors->has('user'))
<small class="text-danger">{{ $errors->first('user') }}</small>
@endif
</div>
<div class="form-group">
<label for="user-permissions">Permissões:</label>
<select name="permissions[]"
style="width: 100%"
multiple
id="user-permissions"
class="form-control">
@if(isset($user))
@foreach($permissions as $permission)
<option value="{{ $permission->id }}"
{{ ($user->hasDirectPermission($permission->slug) ? 'selected' : '') }}
@if(old('$permissions') != null)
{{ (in_array($permission->id, old('permissions')) ? 'selected' : '') }}
@endif
>
{{ $permission->name }}
</option>
@endforeach
@else
@foreach($permissions as $permission)
<option value="{{ $permission->id }}"
@if(old('permissions') != null)
{{ in_array($permission->id, old('permissions')) ? 'selected' : '' }}
@endif
>
{{ $permission->name }}
</option>
@endforeach
@endif
</select>
@if($errors->has('permissions'))
<span class="text-danger">{{ $errors->first('permissions') }}</span>
@endif

View File

@ -1,44 +0,0 @@
@extends('admin')
@section('content')
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Assegnazione Permessi</h1>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
Assegnazione dei permessi ai gruppi
</div>
<div class="panel-body">
<form action="" method="POST">
@csrf
<div class="mb-3">
<label for="permesso" class="form-label">Permesso:</label>
<select name="permesso" id="permesso">
@foreach($permessi as $permesso)
<option value="{{ $permesso->name; }}">{{ $permesso->name; }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="gruppo" class="form-label">Gruppo:</label>
<select name="gruppo" id="gruppo">
@foreach($gruppi as $gruppo)
<option value="{{ $gruppo->name; }}">{{ $gruppo->name; }}</option>
@endforeach
</select>
</div>
<input type="submit" value="submit">
</form>
</div>
</div>
</div>
</div>
@endsection

View File

@ -1,67 +0,0 @@
@extends('admin')
@section('content')
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Gruppi</h1>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
Inserimento dei gruppi
</div>
<div class="panel-body">
<form action="" method="POST">
@csrf
<div class="mb-3">
<label for="gruppo" class="form-label">Gruppo:</label>
<input type="text" class="form-control" name="gruppo" id="gruppo"/>
</div>
<div class="mb-3">
<label for="descrizione" class="form-label">Descrizione:</label>
<textarea name="descrizione" class="form-control" id="descrizione"></textarea>
</div>
<input type="submit" value="submit">
</form>
</div>
</div>
<div class="panel-heading">
Gruppi inseriti
</div>
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover" id="tab_gruppi">
<thead>
<tr>
<th>Gruppo</th>
<th>Descrizione</th>
</tr>
</thead>
<tbody>
@foreach($gruppi as $gruppo)
<tr>
<td>{{ $gruppo->name ?? ''; }}</td>
<td>{{ $gruppo->description ?? ''; }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection
@section('script')
<script>
$(document).ready(function() {
$('#tab_gruppi').DataTable({
responsive: true
});
});
</script>
@endsection

View File

@ -1,67 +0,0 @@
@extends('admin')
@section('content')
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Permessi</h1>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
Inserimento dei permessi
</div>
<div class="panel-body">
<form action="" method="POST">
@csrf
<div class="mb-3">
<label for="permesso" class="form-label">Permesso:</label>
<input type="text" class="form-control" name="permesso" id="permesso"/>
</div>
<div class="mb-3">
<label for="descrizione" class="form-label">Descrizione:</label>
<textarea name="descrizione" class="form-control" id="descrizione"></textarea>
</div>
<input type="submit" value="submit">
</form>
</div>
</div>
<div class="panel-heading">
Permessi inseriti
</div>
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover" id="tab_permessi">
<thead>
<tr>
<th>Permesso</th>
<th>Descrizione</th>
</tr>
</thead>
<tbody>
@foreach($permessi as $permesso)
<tr>
<td>{{ $permesso->name ?? ''; }}</td>
<td>{{ $permesso->description ?? ''; }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection
@section('script')
<script>
$(document).ready(function() {
$('#tab_permessi').DataTable({
responsive: true
});
});
</script>
@endsection

View File

@ -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']);