Compare commits
10 Commits
9f7bab7688
...
235508dd15
Author | SHA1 | Date | |
---|---|---|---|
235508dd15 | |||
b05d49b72b | |||
d554066dd5 | |||
f172afdfc8 | |||
2af799240c | |||
d8a8e363d2 | |||
ce5527ecde | |||
8fc2b6ae83 | |||
401a061aeb | |||
33f6d84f4f |
19
README.md
19
README.md
@ -15,23 +15,16 @@ Al momento sono presenti:
|
|||||||
|
|
||||||
## Installazione
|
## Installazione
|
||||||
- clonare il repository
|
- clonare il repository
|
||||||
- copiare il file .env.example
|
- copiare il file ```.env.example``` in ```.env```
|
||||||
- inserire le informazioni del database (username,password,dbname)
|
- inserire le informazioni del database (username,password,dbname)
|
||||||
- lanciare >composer install
|
- lanciare ``` composer install ```
|
||||||
- lanciare php artisan migrate
|
- lanciare ``` php artisan migrate --seed```
|
||||||
- lanciare i seeds (categorie e utenti di default)
|
- preparare Apache copiando e modificando secondo le proprie impostazioni il file ``` bubofamily.conf ``` in ```/etc/apache2/sites-available ``` e quindi impostare in ```/etc/hosts``` il proprio fqdn relativo al gestionale. Ora applicare la modifica ad apache digitando ``` a2ensite bubofamily.conf``` e poi ``` systemctl restart apache2```
|
||||||
|
- di default si crea l'utente ``` admin ``` con password ```admin ``` per accedere la prima volta.
|
||||||
|
|
||||||
|
|
||||||
## Sviluppatori
|
## Sviluppatori (attualmente)
|
||||||
Flavio Barachino <flavio.barachino@lavorain.cloud>
|
Flavio Barachino <flavio.barachino@lavorain.cloud>
|
||||||
|
|
||||||
### Vuoi partecipare?
|
### Vuoi partecipare?
|
||||||
Scrivimi con le tue proposte, le tue critiche, i tuoi suggerimenti.
|
Scrivimi con le tue proposte, le tue critiche, i tuoi suggerimenti.
|
||||||
|
|
||||||
=======
|
|
||||||
## Sviluppatori
|
|
||||||
Flavio Barachino <flavio.barachino@lavorain.cloud>
|
|
||||||
|
|
||||||
### Vuoi partecipare?
|
|
||||||
Scrivimi con le tue proposte, le tue critiche, i tuoi suggerimenti.
|
|
||||||
|
|
||||||
|
@ -23,4 +23,6 @@ class CondominioController extends Controller
|
|||||||
{
|
{
|
||||||
abort(403);
|
abort(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,58 +4,59 @@ namespace App\Http\Controllers;
|
|||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Junges\ACL\Models\Group;
|
// use Junges\ACL\Models\Group;
|
||||||
use Junges\ACL\Models\Permission;
|
// use Junges\ACL\Models\Permission;
|
||||||
|
use Spatie\Permission\Models\Role;
|
||||||
|
use Spatie\Permission\Models\Permission;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
class Utenti extends Controller
|
class Utenti extends Controller
|
||||||
{
|
{
|
||||||
//
|
|
||||||
public function nuovoGruppo()
|
public function createRole($ruolo)
|
||||||
{
|
{
|
||||||
return view('vendor.junges.form_addGroup',['gruppi'=>Utenti::getGruppi()]);
|
$role=Role::create(['name'=>$ruolo]);
|
||||||
|
return json_encode(Role::all()->pluck('name'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveNuovoGruppo(Request $request)
|
function createPermission($permesso){
|
||||||
{
|
$permission=Permission::create(['name'=>$permesso]);
|
||||||
$group=Group::create(['name' => $request['gruppo'],'description'=>$request['descrizione']]);
|
return json_encode(Permission::all()->pluck('name'));
|
||||||
return view('vendor.junges.form_addGroup',['gruppi'=>Utenti::getGruppi()]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function nuovoPermesso()
|
function userClass() {
|
||||||
{
|
$user=new User();
|
||||||
return view('vendor.junges.form_addPermission',['permessi'=>Utenti::getPermessi()]);
|
return get_class_methods($user);
|
||||||
}
|
|
||||||
public function saveNuovoPermesso(Request $request)
|
|
||||||
{
|
|
||||||
$group=Permission::create(['name' => $request['permesso'],'description'=>$request['descrizione']]);
|
|
||||||
return view('vendor.junges.form_addPermission',['permessi'=>Utenti::getPermessi()]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPermessi()
|
// post del create user
|
||||||
{
|
function createUser(Request $params){
|
||||||
return DB::table('permissions')->orderBy('name')->get();
|
User::addUser($params);
|
||||||
|
return redirect('/admin/users/new');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGruppi()
|
// mostra il form della creazione dell'utente
|
||||||
{
|
function addUser(){
|
||||||
return DB::table('groups')->orderBy('name')->get();
|
$roles = Role::all();
|
||||||
|
$users = User::all();
|
||||||
|
return view('users.create',['ruoli'=>$roles,'users'=>$users]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function vw_assignToGroup()
|
function listUser(){
|
||||||
{
|
$users = User::all();
|
||||||
return view('vendor.junges.assignPermissionToGroup',[
|
return view('users.list',['users'=>$users]);
|
||||||
'permessi'=>Utenti::getPermessi(),
|
|
||||||
'gruppi'=>Utenti::getGruppi(),
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function assignPermissionToGroup(Request $request)
|
function listRoles(){
|
||||||
{
|
$roles = Role::all();
|
||||||
$group=Group::findByName($request['gruppo']);
|
return $roles;
|
||||||
$group->assignPermission($request['permesso']);
|
|
||||||
return view('vendor.junges.assignPermissionToGroup',[
|
|
||||||
'permessi'=>Utenti::getPermessi(),
|
|
||||||
'gruppi'=>Utenti::getGruppi(),
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteUser($id) {
|
||||||
|
User::destroy($id);
|
||||||
|
|
||||||
|
return redirect('/admin/users/new');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,8 @@ class Kernel extends HttpKernel
|
|||||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||||
|
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
|
||||||
|
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
|
||||||
|
'role_or_permission' => \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -2,21 +2,20 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Laravel\Sanctum\HasApiTokens;
|
use Laravel\Sanctum\HasApiTokens;
|
||||||
//use LdapRecord\Laravel\Auth\Authenticatable;
|
use Spatie\Permission\Traits\HasRoles;
|
||||||
use LdapRecord\Laravel\Auth\AuthenticatesWithLdap;
|
use Illuminate\Foundation\Auth\Access\Authorizable;
|
||||||
use Junges\ACL\Concerns\HasGroups;
|
|
||||||
|
|
||||||
|
|
||||||
class User extends Authenticatable
|
class User extends Authenticatable
|
||||||
{
|
{
|
||||||
use HasApiTokens, HasFactory, Notifiable, AuthenticateswithLdap, HasGroups, SoftDeletes;
|
use HasApiTokens, HasFactory, Notifiable, HasRoles,Authorizable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
@ -27,6 +26,7 @@ class User extends Authenticatable
|
|||||||
'name',
|
'name',
|
||||||
'email',
|
'email',
|
||||||
'password',
|
'password',
|
||||||
|
'user_role',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,6 +48,8 @@ class User extends Authenticatable
|
|||||||
'email_verified_at' => 'datetime',
|
'email_verified_at' => 'datetime',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $guard_name = 'web';
|
||||||
|
|
||||||
public function getLdapDomainColumn()
|
public function getLdapDomainColumn()
|
||||||
{
|
{
|
||||||
return 'domain';
|
return 'domain';
|
||||||
@ -68,11 +70,24 @@ class User extends Authenticatable
|
|||||||
{
|
{
|
||||||
return DB::table('users')->where('id','=',$id)->get();
|
return DB::table('users')->where('id','=',$id)->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getUsers()
|
public static function getUsers()
|
||||||
{
|
{
|
||||||
return DB::table('users')->orderBy('name')->get();
|
return DB::table('users')->orderBy('name')->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Aggiunge un utente e assegna un ruolo
|
||||||
|
public static function addUser($params)
|
||||||
|
{
|
||||||
|
self::create([
|
||||||
|
'name'=>$params['name'],
|
||||||
|
'email'=>$params['email'],
|
||||||
|
'password'=>Hash::make($params['password']),
|
||||||
|
])->assignRole($params['role']);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,5 +26,10 @@ class AuthServiceProvider extends ServiceProvider
|
|||||||
$this->registerPolicies();
|
$this->registerPolicies();
|
||||||
|
|
||||||
//
|
//
|
||||||
|
Gate::before(function ($user, $ability) {
|
||||||
|
if ($user->hasRole('admin')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
"php": "^7.3|^8.0",
|
"php": "^7.3|^8.0",
|
||||||
"barryvdh/laravel-dompdf": "^2.0",
|
"barryvdh/laravel-dompdf": "^2.0",
|
||||||
"directorytree/ldaprecord": "^2.9",
|
"directorytree/ldaprecord": "^2.9",
|
||||||
"directorytree/ldaprecord-laravel": "^2.5",
|
|
||||||
"fruitcake/laravel-cors": "^2.0",
|
"fruitcake/laravel-cors": "^2.0",
|
||||||
"guzzlehttp/guzzle": "^7.0.1",
|
"guzzlehttp/guzzle": "^7.0.1",
|
||||||
"laravel-notification-channels/telegram": "^2.0",
|
"laravel-notification-channels/telegram": "^2.0",
|
||||||
@ -20,12 +19,12 @@
|
|||||||
"laravel/tinker": "^2.5",
|
"laravel/tinker": "^2.5",
|
||||||
"laravel/ui": "^3.4",
|
"laravel/ui": "^3.4",
|
||||||
"laraveldaily/laravel-charts": "^0.1.29",
|
"laraveldaily/laravel-charts": "^0.1.29",
|
||||||
"mateusjunges/laravel-acl": "^4.2",
|
|
||||||
"rap2hpoutre/fast-excel": "^3.2",
|
"rap2hpoutre/fast-excel": "^3.2",
|
||||||
"secondtruth/startmin": "^1.1",
|
"secondtruth/startmin": "^1.1",
|
||||||
"sfneal/view-export": "^2.10",
|
"sfneal/view-export": "^2.10",
|
||||||
"snapappointments/bootstrap-select": "^1.13",
|
"snapappointments/bootstrap-select": "^1.13",
|
||||||
"spatie/laravel-backup": "^7.0",
|
"spatie/laravel-backup": "^7.0",
|
||||||
|
"spatie/laravel-permission": "^5.10",
|
||||||
"webklex/laravel-imap": "^2.4"
|
"webklex/laravel-imap": "^2.4"
|
||||||
},
|
},
|
||||||
"require-dev" : {
|
"require-dev" : {
|
||||||
|
1281
composer.lock
generated
1281
composer.lock
generated
File diff suppressed because it is too large
Load Diff
106
config/acl.php
106
config/acl.php
@ -1,106 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Models
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| When using this package, we need to know which Eloquent Model should be used
|
|
||||||
| to retrieve your groups and permissions. Of course, it is just the basics models
|
|
||||||
| needed, but you can use whatever you like.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
'models' => [
|
|
||||||
/*
|
|
||||||
| The model you want to use as Permission model must use the MateusJunges\ACL\Traits\PermissionsTrait
|
|
||||||
*/
|
|
||||||
'permission' => Junges\ACL\Models\Permission::class,
|
|
||||||
|
|
||||||
/*
|
|
||||||
| The model you want to use as Group model must use the MateusJunges\ACL\Traits\GroupsTrait
|
|
||||||
*/
|
|
||||||
'group' => Junges\ACL\Models\Group::class,
|
|
||||||
],
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Route Model Binding
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| If you would like model binding to use a database column other than id when
|
|
||||||
| retrieving a given model class, you may override the getRouteKeyName method
|
|
||||||
| on the Eloquent model with yours. The default key used for route model binding
|
|
||||||
| in this package is the `id` database column. You can modify it by changing the
|
|
||||||
| following configuration:
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
'route_model_binding_keys' => [
|
|
||||||
'group_model' => 'id',
|
|
||||||
'permission_model' => 'id',
|
|
||||||
],
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Tables
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Specify the basics authentication tables that you are using.
|
|
||||||
| Once you required this package, the following tables are
|
|
||||||
| created by default when you run the command
|
|
||||||
|
|
|
||||||
| php artisan migrate
|
|
||||||
|
|
|
||||||
| If you want to change this tables, please keep the basic structure unchanged.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
'tables' => [
|
|
||||||
'groups' => 'groups',
|
|
||||||
'permissions' => 'permissions',
|
|
||||||
'users' => 'users',
|
|
||||||
'group_has_permissions' => 'group_has_permissions',
|
|
||||||
'model_has_permissions' => 'model_has_permissions',
|
|
||||||
'model_has_groups' => 'model_has_groups',
|
|
||||||
],
|
|
||||||
|
|
||||||
'column_names' => [
|
|
||||||
'group_pivot_key' => null,
|
|
||||||
'permission_pivot_key' => null,
|
|
||||||
'model_morph_key' => 'model_id',
|
|
||||||
'team_foreign_key' => 'team_id'
|
|
||||||
],
|
|
||||||
|
|
||||||
'teams' => false,
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Ignition Solution Suggestions
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| To enable the ignition solutions for laravel-acl, set this flag to true.
|
|
||||||
|
|
|
||||||
| The solutions will then be automatically registered with ignition if its installed.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
'offer_solutions' => false,
|
|
||||||
|
|
||||||
'register_permission_check_method' => true,
|
|
||||||
|
|
||||||
'cache' => [
|
|
||||||
/*
|
|
||||||
* All permissions are cached for 24 hours by default. If permissions or groups are updated,
|
|
||||||
* then the cache is flushed automatically.
|
|
||||||
*/
|
|
||||||
'expiration_time' => DateInterval::createFromDateString('24 hours'),
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The cache key used to store permissions.
|
|
||||||
*/
|
|
||||||
'key' => 'junges.acl.cache',
|
|
||||||
|
|
||||||
/*
|
|
||||||
* You can optionally specify a cache driver to use for permissions caching using
|
|
||||||
* store drivers listed in config/cache.php.
|
|
||||||
*/
|
|
||||||
'store' => 'default'
|
|
||||||
]
|
|
||||||
];
|
|
@ -162,6 +162,7 @@ return [
|
|||||||
Illuminate\Validation\ValidationServiceProvider::class,
|
Illuminate\Validation\ValidationServiceProvider::class,
|
||||||
Illuminate\View\ViewServiceProvider::class,
|
Illuminate\View\ViewServiceProvider::class,
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Package Service Providers...
|
* Package Service Providers...
|
||||||
*/
|
*/
|
||||||
@ -174,6 +175,7 @@ return [
|
|||||||
// App\Providers\BroadcastServiceProvider::class,
|
// App\Providers\BroadcastServiceProvider::class,
|
||||||
App\Providers\EventServiceProvider::class,
|
App\Providers\EventServiceProvider::class,
|
||||||
App\Providers\RouteServiceProvider::class,
|
App\Providers\RouteServiceProvider::class,
|
||||||
|
Spatie\Permission\PermissionServiceProvider::class,
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
|
@ -60,26 +60,14 @@ return [
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
'providers' => [
|
'providers' => [
|
||||||
'ldap' => [
|
'users' => [
|
||||||
'driver' => 'ldap', //'eloquent',
|
'driver' => 'eloquent',
|
||||||
'model' => LdapRecord\Models\ActiveDirectory\User::class, //App\Models\User::class,
|
'model' => App\Models\User::class,
|
||||||
'rules' => [
|
|
||||||
App\Ldap\Rules\OnlyInGroupUsers::class,
|
|
||||||
],
|
|
||||||
'database' => [
|
|
||||||
'model' => App\Models\User::class,
|
|
||||||
'sync_passwords'=> false,
|
|
||||||
'sync_attributes' => [
|
|
||||||
'name' => 'displayname',
|
|
||||||
'email' => 'mail',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
|
/*'users' => [
|
||||||
'users' => [
|
|
||||||
'driver' => 'database',
|
'driver' => 'database',
|
||||||
'table' => 'users',
|
'table' => 'users',
|
||||||
],
|
],*/
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
161
config/permission.php
Normal file
161
config/permission.php
Normal 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',
|
||||||
|
],
|
||||||
|
];
|
@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
class CreatePermissionsTable extends Migration
|
|
||||||
{
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
$permissionsTable = config('acl.tables.permissions', 'permissions');
|
|
||||||
Schema::create($permissionsTable, function (Blueprint $table) {
|
|
||||||
$table->bigIncrements('id');
|
|
||||||
$table->string('name');
|
|
||||||
$table->string('guard_name');
|
|
||||||
$table->text('description')->nullable();
|
|
||||||
$table->softDeletes();
|
|
||||||
$table->timestamps();
|
|
||||||
|
|
||||||
$table->unique(['name', 'guard_name']);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
$tables = config('acl.tables');
|
|
||||||
Schema::dropIfExists($tables['permissions']);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
class CreateGroupsTable extends Migration
|
|
||||||
{
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
$groupsTable = config('acl.tables.groups', 'groups');
|
|
||||||
$teams = config('acl.teams');
|
|
||||||
$columnNames = config('acl.column_names');
|
|
||||||
|
|
||||||
Schema::create($groupsTable, function (Blueprint $table) use ($teams, $columnNames) {
|
|
||||||
$table->bigIncrements('id');
|
|
||||||
|
|
||||||
if ($teams || config("acl.testing")) {
|
|
||||||
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
|
|
||||||
$table->index($columnNames['team_foreign_key'], 'groups_team_foreign_key_index');
|
|
||||||
}
|
|
||||||
|
|
||||||
$table->string('name');
|
|
||||||
$table->string('guard_name');
|
|
||||||
$table->text('description')->nullable();
|
|
||||||
$table->softDeletes();
|
|
||||||
$table->timestamps();
|
|
||||||
|
|
||||||
if ($teams || config('acl.testing')) {
|
|
||||||
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
|
|
||||||
} else {
|
|
||||||
$table->unique(['name', 'guard_name']);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
$groupsTable = config('acl.tables.groups', 'groups');
|
|
||||||
Schema::dropIfExists($groupsTable);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Junges\ACL\AclRegistrar;
|
|
||||||
|
|
||||||
class CreateModelHasPermissionsTable extends Migration
|
|
||||||
{
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
$columnNames = config('acl.column_names');
|
|
||||||
|
|
||||||
$modelHasPermissions = config('acl.tables.model_has_permissions', 'model_has_permissions');
|
|
||||||
$permissionsTable = config('acl.tables.permissions', 'permissions');
|
|
||||||
$teams = config('acl.teams');
|
|
||||||
|
|
||||||
Schema::create($modelHasPermissions, function (Blueprint $table) use ($permissionsTable, $columnNames, $teams) {
|
|
||||||
$table->unsignedBigInteger(AclRegistrar::$pivotPermission);
|
|
||||||
$table->string('model_type');
|
|
||||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
|
||||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_id_model_type_index');
|
|
||||||
|
|
||||||
$table->foreign(AclRegistrar::$pivotPermission)
|
|
||||||
->references('id')
|
|
||||||
->on($permissionsTable)
|
|
||||||
->cascadeOnDelete();
|
|
||||||
|
|
||||||
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'], AclRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
|
||||||
'model_has_permissions_permission_model_type_primary');
|
|
||||||
} else {
|
|
||||||
$table->primary([AclRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
|
||||||
'model_has_permissions_permission_model_type_primary');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
$modelHasPermissionTable = config('acl.tables.model_has_permissions', 'model_has_permissions');
|
|
||||||
Schema::dropIfExists($modelHasPermissionTable);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Junges\ACL\AclRegistrar;
|
|
||||||
|
|
||||||
class CreateModelHasGroupsTable extends Migration
|
|
||||||
{
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
$columnNames = config('acl.column_names');
|
|
||||||
$modelHasGroups = config('acl.tables.model_has_groups', 'model_has_groups');
|
|
||||||
$groupsTable = config('acl.tables.groups', 'groups');
|
|
||||||
$teams = config('acl.teams');
|
|
||||||
|
|
||||||
Schema::create($modelHasGroups, function (Blueprint $table) use ($groupsTable, $columnNames, $teams) {
|
|
||||||
$table->unsignedBigInteger(AclRegistrar::$pivotGroup);
|
|
||||||
|
|
||||||
$table->string('model_type');
|
|
||||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
|
||||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_groups_model_id_model_type_index');
|
|
||||||
|
|
||||||
$table->foreign(AclRegistrar::$pivotGroup)
|
|
||||||
->references('id')
|
|
||||||
->on($groupsTable)
|
|
||||||
->cascadeOnDelete();
|
|
||||||
|
|
||||||
if ($teams) {
|
|
||||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
|
||||||
$table->index($columnNames['team_foreign_key'], 'model_has_groups_team_foreign_key_index');
|
|
||||||
|
|
||||||
$table->primary([$columnNames['team_foreign_key'], AclRegistrar::$pivotGroup, $columnNames['model_morph_key'], 'model_type'],
|
|
||||||
'model_has_groups_group_model_type_primary');
|
|
||||||
} else {
|
|
||||||
$table->primary([AclRegistrar::$pivotGroup, $columnNames['model_morph_key'], 'model_type'],
|
|
||||||
'model_has_groups_group_model_type_primary');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
$modelHasGroupsTable = config('acl.tables.model_has_groups', 'model_has_groups');
|
|
||||||
Schema::dropIfExists($modelHasGroupsTable);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Junges\ACL\AclRegistrar;
|
|
||||||
|
|
||||||
class CreateGroupHasPermissionsTable extends Migration
|
|
||||||
{
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
$groupHasPermissionTable = config('acl.tables.group_has_permissions', 'group_has_permissions');
|
|
||||||
$groupsTable = config('acl.tables.groups', 'groups');
|
|
||||||
$permissionsTable = config('acl.tables.permissions', 'permissions');
|
|
||||||
|
|
||||||
Schema::create($groupHasPermissionTable, function (Blueprint $table) use ($groupsTable, $permissionsTable) {
|
|
||||||
$table->unsignedBigInteger(AclRegistrar::$pivotPermission);
|
|
||||||
$table->unsignedBigInteger(AclRegistrar::$pivotGroup);
|
|
||||||
|
|
||||||
$table->foreign(AclRegistrar::$pivotPermission)
|
|
||||||
->references('id')
|
|
||||||
->on($permissionsTable)
|
|
||||||
->cascadeOnDelete();
|
|
||||||
|
|
||||||
$table->foreign(AclRegistrar::$pivotGroup)
|
|
||||||
->references('id')
|
|
||||||
->on($groupsTable)
|
|
||||||
->cascadeOnDelete();
|
|
||||||
|
|
||||||
$table->primary([AclRegistrar::$pivotPermission, AclRegistrar::$pivotGroup], 'group_has_permission_permission_id_group_id_primary');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
$groupHasPermissionsTable = config('acl.tables.group_has_permissions', 'group_has_permissions');
|
|
||||||
|
|
||||||
Schema::dropIfExists($groupHasPermissionsTable);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
class ColumnUsersRoles extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::table('users', function (Blueprint $table) {
|
|
||||||
//
|
|
||||||
$table->softDeletes();
|
|
||||||
$table->string('user_role',25)->default('user')->nullable(false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::table('users', function (Blueprint $table) {
|
|
||||||
//
|
|
||||||
$table->dropColumn('user_role');
|
|
||||||
$table->dropSoftDeletes();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -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']);
|
||||||
|
}
|
||||||
|
}
|
@ -18,6 +18,7 @@ class DatabaseSeeder extends Seeder
|
|||||||
UserSeeder::class,
|
UserSeeder::class,
|
||||||
TagSeeder::class,
|
TagSeeder::class,
|
||||||
CategorieSeeder::class,
|
CategorieSeeder::class,
|
||||||
|
RoleSeeder::class,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
83
database/seeders/RoleSeeder.php
Normal file
83
database/seeders/RoleSeeder.php
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Spatie\Permission\Models\Permission;
|
||||||
|
use Spatie\Permission\Models\Role;
|
||||||
|
use Spatie\Permission\PermissionRegistrar;
|
||||||
|
|
||||||
|
class RoleSeeder extends Seeder
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
// Role Creation
|
||||||
|
$role_admin = Role::create([
|
||||||
|
'name' => 'admin'
|
||||||
|
]);
|
||||||
|
$role_user = Role::create([
|
||||||
|
'name' => 'user'
|
||||||
|
]);
|
||||||
|
$role_guest = Role::create([
|
||||||
|
'name' => 'guest'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Permission Creation
|
||||||
|
Permission::create([
|
||||||
|
'name' => 'conti'
|
||||||
|
]);
|
||||||
|
Permission::create([
|
||||||
|
'name' => 'consumi'
|
||||||
|
]);
|
||||||
|
Permission::create([
|
||||||
|
'name' => 'automobili'
|
||||||
|
]);
|
||||||
|
Permission::create([
|
||||||
|
'name' => 'contatti'
|
||||||
|
]);
|
||||||
|
Permission::create([
|
||||||
|
'name' => 'affitti'
|
||||||
|
]);
|
||||||
|
Permission::create([
|
||||||
|
'name' => 'progetti'
|
||||||
|
]);
|
||||||
|
Permission::create([
|
||||||
|
'name' => 'amministrazione'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Assegnazione permessi al ruolo user
|
||||||
|
$role_user->givePermissionTo('affitti');
|
||||||
|
$role_user->givePermissionTo('automobili');
|
||||||
|
$role_user->givePermissionTo('contatti');
|
||||||
|
$role_user->givePermissionTo('consumi');
|
||||||
|
$role_user->givePermissionTo('conti');
|
||||||
|
$role_user->givePermissionTo('progetti');
|
||||||
|
// Assegnazione permessi al ruolo guest
|
||||||
|
$role_guest->givePermissionTo('affitti');
|
||||||
|
|
||||||
|
$admin = User::create([
|
||||||
|
'name'=>'Amministratore',
|
||||||
|
'email'=>'admin@localhost.local',
|
||||||
|
'password'=>Hash::make('password'),
|
||||||
|
])->assignRole($role_admin);
|
||||||
|
|
||||||
|
$user = User::create([
|
||||||
|
'name'=>'Utente',
|
||||||
|
'email'=>'user@localhost.local',
|
||||||
|
'password'=>Hash::make('password'),
|
||||||
|
])->assignRole($role_user);
|
||||||
|
|
||||||
|
$guest = User::create([
|
||||||
|
'name'=>'Guest',
|
||||||
|
'email'=>'guest@localhost.local',
|
||||||
|
'password'=>Hash::make('password'),
|
||||||
|
])->assignRole($role_guest);
|
||||||
|
}
|
||||||
|
}
|
@ -22,14 +22,9 @@ class UserSeeder extends Seeder
|
|||||||
'name'=>'SystemUser',
|
'name'=>'SystemUser',
|
||||||
'email'=>'system@localhost.local',
|
'email'=>'system@localhost.local',
|
||||||
'password'=>Hash::make(Str::random(16)),
|
'password'=>Hash::make(Str::random(16)),
|
||||||
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
DB::table('users')->insert(
|
|
||||||
[
|
|
||||||
'name'=>'admin',
|
|
||||||
'email'=>env('SYSADMIN_MAIL'),
|
|
||||||
'password'=>Hash::make('admin'),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
<li><a href="/admin"><i class="fa fa-dashboard fa-fw"></i>Riepilogo</a>
|
<li><a href="/admin"><i class="fa fa-dashboard fa-fw"></i>Riepilogo</a>
|
||||||
</li>
|
</li>
|
||||||
|
@can('conti')
|
||||||
<li><a href="#"><i class="fa fa-money fa-fw"></i>Spese/Incassi<span
|
<li><a href="#"><i class="fa fa-money fa-fw"></i>Spese/Incassi<span
|
||||||
class="fa arrow"></span></a>
|
class="fa arrow"></span></a>
|
||||||
|
|
||||||
<ul class="nav nav-second-level">
|
<ul class="nav nav-second-level">
|
||||||
<li><a href="{{ route('movimenti'); }}">Lista Movimenti</a></li>
|
<li><a href="{{ route('movimenti'); }}">Lista Movimenti</a></li>
|
||||||
<li><a href="{{ route('categorie'); }}">Categorie</a></li>
|
<li><a href="{{ route('categorie'); }}">Categorie</a></li>
|
||||||
@ -17,7 +19,9 @@
|
|||||||
<li><a href="{{ route('importCR'); }}"><i
|
<li><a href="{{ route('importCR'); }}"><i
|
||||||
class="fa fa-upload fa-fw"></i>Importa Estratto CR</a></li>
|
class="fa fa-upload fa-fw"></i>Importa Estratto CR</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
|
|
||||||
</ul> <!-- /.nav-second-level --></li>
|
</ul> <!-- /.nav-second-level --></li>
|
||||||
|
@endcan @can('consumi')
|
||||||
<li><a href="#"><i class="fa fa-industry fa-fw"></i> Consumi <span
|
<li><a href="#"><i class="fa fa-industry fa-fw"></i> Consumi <span
|
||||||
class="fa arrow"></span></a>
|
class="fa arrow"></span></a>
|
||||||
|
|
||||||
@ -28,8 +32,10 @@
|
|||||||
<li><a href="{{ route('enel'); }}"><i class="fa fa-flash fa-fw"></i>Energia
|
<li><a href="{{ route('enel'); }}"><i class="fa fa-flash fa-fw"></i>Energia
|
||||||
Elettrica</a></li>
|
Elettrica</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
|
@endcan @can('automobili')
|
||||||
<li><a href="{{ route('auto_list'); }}"><i class="fa fa-car fa-fw"></i>
|
<li><a href="{{ route('auto_list'); }}"><i class="fa fa-car fa-fw"></i>
|
||||||
Automobili <span class="fa arrow"></span></a></li>
|
Automobili <span class="fa arrow"></span></a></li>
|
||||||
|
@endcan @can('contatti')
|
||||||
<li><a href="#"><i class="fa fa-phone-square fa-fw"></i> Contatti <span
|
<li><a href="#"><i class="fa fa-phone-square fa-fw"></i> Contatti <span
|
||||||
class="fa arrow"></span></a>
|
class="fa arrow"></span></a>
|
||||||
|
|
||||||
@ -40,15 +46,21 @@
|
|||||||
<li><a href="{{ route('newContact'); }}"><i class="fa fa-plus fa-fw"></i>Nuovo
|
<li><a href="{{ route('newContact'); }}"><i class="fa fa-plus fa-fw"></i>Nuovo
|
||||||
contatto</a></li>
|
contatto</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
|
@endcan @can('progetti')
|
||||||
<li><a href="{{ route('progetti'); }}"><i class="fa fa-list fa-fw"></i>
|
<li><a href="{{ route('progetti'); }}"><i class="fa fa-list fa-fw"></i>
|
||||||
Progetti <span class="fa arrow"></span></a></li>
|
Progetti <span class="fa arrow"></span></a></li>
|
||||||
|
@endcan @can('amministrazione')
|
||||||
<li><a href="#"><i class="fa fa-gears fa-fw"></i>Amministrazione<span
|
<li><a href="#"><i class="fa fa-gears fa-fw"></i>Amministrazione<span
|
||||||
class="fa arrow"></span></a>
|
class="fa arrow"></span></a>
|
||||||
<ul class="nav nav-second-level">
|
<ul class="nav nav-second-level">
|
||||||
<li><a class="active" href="#">Utenti</a></li>
|
<li><a class="active" href="/admin/users/new">Nuovo Utente</a></li>
|
||||||
<li><a class="active" href="/admin/group/new">Gruppi</a></li>
|
<!--
|
||||||
<li><a class="active" href="/admin/permesso/new">Permessi</a></li>
|
<li><a class="active" href="/admin/users/newRole">Gruppi</a></li>
|
||||||
<li><a class="active" href="/admin/permesso/assign">Assegna Permessi
|
<li><a class="active" href="/admin/users/newPermission">Permessi</a></li>
|
||||||
ai gruppi</a></li>
|
-->
|
||||||
|
<li><a class="active" href="/admin/users/assignRole">Assegna Ruoli</a></li>
|
||||||
|
<!--
|
||||||
<li><a href="/login">Login Page</a></li>
|
<li><a href="/login">Login Page</a></li>
|
||||||
|
-->
|
||||||
</ul> <!-- /.nav-second-level --></li>
|
</ul> <!-- /.nav-second-level --></li>
|
||||||
|
@endcan
|
||||||
|
@ -7,10 +7,15 @@
|
|||||||
<ul class="dropdown-menu dropdown-user">
|
<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-user fa-fw"></i> Profilo utente</a></li>
|
||||||
<li><a href="#"><i class="fa fa-gear fa-fw"></i> Impostazioni</a></li>
|
<li><a href="#"><i class="fa fa-gear fa-fw"></i> Impostazioni</a></li>
|
||||||
|
@role('admin')
|
||||||
|
<li class="divider"></li>
|
||||||
|
<li><a href="/admin/users/new"><i class="fa fa-gear fa-fw"></i> Gestisci Utenti</a></li>
|
||||||
|
@endrole
|
||||||
<li class="divider"></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><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 class="divider"></li>
|
||||||
<li><a href="{{ route('logout'); }}"><i class="fa fa-sign-out fa-fw"></i>
|
<li><a href="{{ route('logout'); }}"><i class="fa fa-sign-out fa-fw"></i>
|
||||||
Logout</a></li>
|
Logout</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
|
<!-- https://spatie.be/docs/laravel-permission/v5/basic-usage/new-app -->
|
||||||
<!-- /USERMENU -->
|
<!-- /USERMENU -->
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@hasanyrole('user|admin')
|
||||||
<!-- WIDGET Bilancio -->
|
<!-- WIDGET Bilancio -->
|
||||||
<div class="col-lg-4 col-md-8">
|
<div class="col-lg-4 col-md-8">
|
||||||
<div class="panel panel-primary">
|
<div class="panel panel-primary">
|
||||||
@ -52,6 +53,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@endhasanyrole
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
70
resources/views/users/create.blade.php
Normal file
70
resources/views/users/create.blade.php
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
@extends('admin') @section('content')
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<h1 class="page-header">Nuovo utente</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="container">
|
||||||
|
<!-- INIZIO CONTENUTO -->
|
||||||
|
<div class="row">
|
||||||
|
<form action="" method="post">
|
||||||
|
@csrf
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-6">
|
||||||
|
<label for="name" class="form-label">Nome</label> <input
|
||||||
|
type="text" class="form-control" id="name" name="name">
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-6">
|
||||||
|
<label for="email" class="form-label">E-Mail</label> <input
|
||||||
|
type="text" class="form-control" id="email" name="email">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-6">
|
||||||
|
<label for="password" class="form-label">Password</label> <input
|
||||||
|
type="password" class="form-control" id="password" name="password">
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-6">
|
||||||
|
<label for="role" class="form-label">Ruolo</label> <select
|
||||||
|
class="form-control" id="role" name="role"> @foreach($ruoli as
|
||||||
|
$ruolo)
|
||||||
|
<option value="{{ $ruolo->id }}">{{$ruolo->name}}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<input type="submit" name="submit" value="Nuovo">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-striped table-bordered table-hover"
|
||||||
|
id="users">
|
||||||
|
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Nome</th>
|
||||||
|
<th>Email</th>
|
||||||
|
<th>Azioni</th>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach($users as $user)
|
||||||
|
<tr>
|
||||||
|
<td>{{ $user->name }}</td>
|
||||||
|
<td>{{ $user->email }}</td>
|
||||||
|
<td><a href="/admin/users/delete/{{ $user->id }}" class="button">Cancella</a></td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- FINE CONTENUTO -->
|
||||||
|
</div>
|
||||||
|
@endsection
|
@ -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>
|
|
@ -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>
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -32,6 +32,7 @@ Route::get('/', [MovimentiController::class,'dashboard']);
|
|||||||
Route::get('logout', function(){ Auth::logout(); return redirect('login'); })->name('logout');
|
Route::get('logout', function(){ Auth::logout(); return redirect('login'); })->name('logout');
|
||||||
|
|
||||||
// MOVIMENTI
|
// MOVIMENTI
|
||||||
|
Route::group(['middleware'=>['permission:conti']], function(){
|
||||||
Route::post('movimenti/spesa',[MovimentiController::class,'insMovimentiSpesa']);
|
Route::post('movimenti/spesa',[MovimentiController::class,'insMovimentiSpesa']);
|
||||||
Route::post('movimenti/entrata',[MovimentiController::class,'insMovimentiEntrata']);
|
Route::post('movimenti/entrata',[MovimentiController::class,'insMovimentiEntrata']);
|
||||||
Route::get('movimenti',[MovimentiController::class,'listMovimenti'])->name('movimenti');
|
Route::get('movimenti',[MovimentiController::class,'listMovimenti'])->name('movimenti');
|
||||||
@ -64,6 +65,7 @@ Route::get('/', [MovimentiController::class,'dashboard']);
|
|||||||
// Richiami di servizio da jquery
|
// Richiami di servizio da jquery
|
||||||
Route::get('service/catlist', [CategorieController::class,'apiList']);
|
Route::get('service/catlist', [CategorieController::class,'apiList']);
|
||||||
Route::get('service/taglist', [TagController::class,'apiList']);
|
Route::get('service/taglist', [TagController::class,'apiList']);
|
||||||
|
Route::get('service/rolesList', [Utenti::class,'listRoles']);
|
||||||
|
|
||||||
// TAGS
|
// TAGS
|
||||||
Route::get('tags', [TagController::class,'listTags'])->name('tags');
|
Route::get('tags', [TagController::class,'listTags'])->name('tags');
|
||||||
@ -71,15 +73,17 @@ Route::get('/', [MovimentiController::class,'dashboard']);
|
|||||||
Route::get('tags/modify/{id}', [TagController::class,'updateTag']);
|
Route::get('tags/modify/{id}', [TagController::class,'updateTag']);
|
||||||
Route::post('tags/modify', [TagController::class,'updatePostTag']);
|
Route::post('tags/modify', [TagController::class,'updatePostTag']);
|
||||||
Route::get('tags/delete/{id}',[TagController::class,'deleteTag']);
|
Route::get('tags/delete/{id}',[TagController::class,'deleteTag']);
|
||||||
|
});
|
||||||
// CONSUMI
|
// CONSUMI
|
||||||
|
Route::group(['middleware'=>['permission:consumi']], function(){
|
||||||
Route::get('consumi/gas', [ContatoreGasController::class,'listLettureGas'])->name('gas');
|
Route::get('consumi/gas', [ContatoreGasController::class,'listLettureGas'])->name('gas');
|
||||||
Route::post('consumi/gas', [ContatoreGasController::class,'insLettureGas']);
|
Route::post('consumi/gas', [ContatoreGasController::class,'insLettureGas']);
|
||||||
Route::get('consumi/enel', [ContatoreEnElController::class,'listLettureEnel'])->name('enel');
|
Route::get('consumi/enel', [ContatoreEnElController::class,'listLettureEnel'])->name('enel');
|
||||||
Route::post('consumi/enel', [ContatoreEnElController::class,'insLettureEnel']);
|
Route::post('consumi/enel', [ContatoreEnElController::class,'insLettureEnel']);
|
||||||
|
});
|
||||||
|
|
||||||
// AUTOMOBILI
|
// AUTOMOBILI
|
||||||
|
Route::group(['middleware'=>['permission:automobili']], function(){
|
||||||
Route::get('auto', [AutoController::class, 'index'])->name('auto_list');
|
Route::get('auto', [AutoController::class, 'index'])->name('auto_list');
|
||||||
Route::get('auto/new', [AutoController::class, 'newAuto'])->name('auto_new');
|
Route::get('auto/new', [AutoController::class, 'newAuto'])->name('auto_new');
|
||||||
Route::post('auto/new', [AutoController::class, 'saveAuto'])->name('auto_save');
|
Route::post('auto/new', [AutoController::class, 'saveAuto'])->name('auto_save');
|
||||||
@ -97,8 +101,9 @@ Route::get('/', [MovimentiController::class,'dashboard']);
|
|||||||
Route::post('auto/accessori', [AutoController::class, 'saveAccessori']);
|
Route::post('auto/accessori', [AutoController::class, 'saveAccessori']);
|
||||||
Route::get('auto/operazioni', [AutoController::class, 'getOperazioni']);
|
Route::get('auto/operazioni', [AutoController::class, 'getOperazioni']);
|
||||||
Route::get('auto/operazioni/pdf', [AutoController::class, 'exportPdfOperazioni']);
|
Route::get('auto/operazioni/pdf', [AutoController::class, 'exportPdfOperazioni']);
|
||||||
|
});
|
||||||
// CONTATTI
|
// CONTATTI
|
||||||
|
Route::group(['middleware'=>['permission:contatti']], function(){
|
||||||
Route::get('contatti', [AnagraficaController::class, 'listContact'])->name('contatti');
|
Route::get('contatti', [AnagraficaController::class, 'listContact'])->name('contatti');
|
||||||
Route::get('contatti/new', [AnagraficaController::class, 'newContact'])->name('newContact');
|
Route::get('contatti/new', [AnagraficaController::class, 'newContact'])->name('newContact');
|
||||||
Route::post('contatti/new', [AnagraficaController::class, 'insContact']);
|
Route::post('contatti/new', [AnagraficaController::class, 'insContact']);
|
||||||
@ -106,16 +111,25 @@ Route::get('/', [MovimentiController::class,'dashboard']);
|
|||||||
Route::get('contatti/scheda', [AnagraficaController::class, 'getScheda']);
|
Route::get('contatti/scheda', [AnagraficaController::class, 'getScheda']);
|
||||||
Route::get('contatti/addOther', [AnagraficaController::class, 'insOtherContact']);
|
Route::get('contatti/addOther', [AnagraficaController::class, 'insOtherContact']);
|
||||||
Route::post('contatti/addOther', [AnagraficaController::class, 'saveOtherContact']);
|
Route::post('contatti/addOther', [AnagraficaController::class, 'saveOtherContact']);
|
||||||
|
});
|
||||||
|
|
||||||
// GRUPPI E PERMESSI
|
// GRUPPI E PERMESSI
|
||||||
Route::get('group/new', [Utenti::class, 'nuovoGruppo']);
|
Route::group(['middleware'=>['permission:amministrazione']], function(){
|
||||||
|
/*
|
||||||
|
Route::get('role/new/{ruolo}', [Utenti::class, 'createRole']);
|
||||||
Route::post('group/new', [Utenti::class, 'saveNuovoGruppo']);
|
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::post('permesso/new', [Utenti::class, 'saveNuovoPermesso']);
|
||||||
Route::get('permesso/assign', [Utenti::class, 'vw_assignToGroup']);
|
Route::get('permesso/assign', [Utenti::class, 'vw_assignToGroup']);
|
||||||
Route::post('permesso/assign', [Utenti::class, 'assignPermissionToGroup']);
|
Route::post('permesso/assign', [Utenti::class, 'assignPermissionToGroup']);
|
||||||
|
*/
|
||||||
|
Route::get('users/new',[Utenti::class,'addUser']);
|
||||||
|
Route::post('users/new',[Utenti::class,'createUser']);
|
||||||
|
Route::get('users/roles',[Utenti::class,'listRoles']);
|
||||||
|
Route::get('users/delete/{id}',[Utenti::class,'deleteUser']);
|
||||||
|
});
|
||||||
// PROGETTI
|
// PROGETTI
|
||||||
|
Route::group(['middleware'=>['permission:progetti']], function(){
|
||||||
Route::get('progetti', [ProgettiController::class, 'listaProgetto'])->name('progetti');
|
Route::get('progetti', [ProgettiController::class, 'listaProgetto'])->name('progetti');
|
||||||
Route::post('progetti/new', [ProgettiController::class, 'salvaProgetto']);
|
Route::post('progetti/new', [ProgettiController::class, 'salvaProgetto']);
|
||||||
Route::get('progetti/new', [ProgettiController::class, 'nuovoProgetto'])->name('nuovoProgetto');
|
Route::get('progetti/new', [ProgettiController::class, 'nuovoProgetto'])->name('nuovoProgetto');
|
||||||
@ -126,11 +140,14 @@ Route::get('/', [MovimentiController::class,'dashboard']);
|
|||||||
Route::get('progetti/detail/edit/{id}', [RigaProgettoController::class, 'editRiga']);
|
Route::get('progetti/detail/edit/{id}', [RigaProgettoController::class, 'editRiga']);
|
||||||
Route::post('progetti/rigaupdate', [RigaProgettoController::class, 'updateRiga']);
|
Route::post('progetti/rigaupdate', [RigaProgettoController::class, 'updateRiga']);
|
||||||
Route::get('progetti/coordinatori', [ProgettiController::class, 'getCoordinatori']);
|
Route::get('progetti/coordinatori', [ProgettiController::class, 'getCoordinatori']);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
/// TEST ROUTES
|
/// TEST ROUTES
|
||||||
Route::get('test/fullcalendar', [FullCalenderController::class, 'index']);
|
Route::get('test/fullcalendar', [FullCalenderController::class, 'index']);
|
||||||
Route::post('test/fullcalendar', [FullCalenderController::class, 'ajax']);
|
Route::post('test/fullcalendar', [FullCalenderController::class, 'ajax']);
|
||||||
Route::get('test/condominio',[CondominioController::class,'testPdf']);
|
Route::get('test/condominio',[CondominioController::class,'testPdf']);
|
||||||
Route::get('test/err403',[CondominioController::class,'err403']);
|
Route::get('test/err403',[CondominioController::class,'err403']);
|
||||||
|
Route::get('test/user_role',[CondominioController::class,'user_role']);
|
||||||
|
Route::get('test/userclass',[Utenti::class,'userClass']);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user