Inserito le role e utenti demo nel seeder
This commit is contained in:
		
							parent
							
								
									d8a8e363d2
								
							
						
					
					
						commit
						2af799240c
					
				@ -2,22 +2,19 @@
 | 
			
		||||
 | 
			
		||||
namespace App\Models;
 | 
			
		||||
 | 
			
		||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
 | 
			
		||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
 | 
			
		||||
// 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\AuthenticatesWithLdap;
 | 
			
		||||
use Illuminate\Contracts\Auth\Access\Authorizable ;
 | 
			
		||||
use Spatie\Permission\Traits\HasRole;
 | 
			
		||||
use Spatie\Permission\Traits\HasRoles;
 | 
			
		||||
use Illuminate\Foundation\Auth\Access\Authorizable;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class User extends Authenticatable
 | 
			
		||||
{
 | 
			
		||||
    use HasApiTokens, HasFactory, Notifiable, AuthenticateswithLdap, HasRoles;
 | 
			
		||||
    use HasApiTokens, HasFactory, Notifiable, HasRoles,Authorizable;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The attributes that are mass assignable.
 | 
			
		||||
@ -50,6 +47,8 @@ class User extends Authenticatable
 | 
			
		||||
        'email_verified_at' => 'datetime',
 | 
			
		||||
    ];
 | 
			
		||||
    
 | 
			
		||||
    protected $guard_name = 'web';
 | 
			
		||||
 | 
			
		||||
    public function getLdapDomainColumn()
 | 
			
		||||
    {
 | 
			
		||||
    	return 'domain';
 | 
			
		||||
 | 
			
		||||
@ -26,10 +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');
 | 
			
		||||
        Gate::before(function ($user, $ability) {
 | 
			
		||||
            if ($user->hasRole('admin')) {
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -11,7 +11,6 @@
 | 
			
		||||
		"php": "^7.3|^8.0",
 | 
			
		||||
		"barryvdh/laravel-dompdf": "^2.0",
 | 
			
		||||
		"directorytree/ldaprecord": "^2.9",
 | 
			
		||||
		"directorytree/ldaprecord-laravel": "^2.5",
 | 
			
		||||
		"fruitcake/laravel-cors": "^2.0",
 | 
			
		||||
		"guzzlehttp/guzzle": "^7.0.1",
 | 
			
		||||
		"laravel-notification-channels/telegram": "^2.0",
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										1004
									
								
								composer.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1004
									
								
								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'
 | 
			
		||||
    ]
 | 
			
		||||
];
 | 
			
		||||
@ -161,7 +161,7 @@ return [
 | 
			
		||||
        Illuminate\Translation\TranslationServiceProvider::class,
 | 
			
		||||
        Illuminate\Validation\ValidationServiceProvider::class,
 | 
			
		||||
        Illuminate\View\ViewServiceProvider::class,
 | 
			
		||||
        Spatie\Permission\PermissionServiceProvider::class,
 | 
			
		||||
       
 | 
			
		||||
 | 
			
		||||
        /*
 | 
			
		||||
         * Package Service Providers...
 | 
			
		||||
@ -175,6 +175,7 @@ return [
 | 
			
		||||
        // App\Providers\BroadcastServiceProvider::class,
 | 
			
		||||
        App\Providers\EventServiceProvider::class,
 | 
			
		||||
        App\Providers\RouteServiceProvider::class,
 | 
			
		||||
        Spatie\Permission\PermissionServiceProvider::class,
 | 
			
		||||
 | 
			
		||||
    ],
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -60,26 +60,14 @@ return [
 | 
			
		||||
    */
 | 
			
		||||
 | 
			
		||||
    'providers' => [
 | 
			
		||||
        'ldap' => [
 | 
			
		||||
            'driver' => 'ldap', //'eloquent',
 | 
			
		||||
            'model' => LdapRecord\Models\ActiveDirectory\User::class,	//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' => [
 | 
			
		||||
            'driver' => 'eloquent',
 | 
			
		||||
            'model' => App\Models\User::class,
 | 
			
		||||
        ],
 | 
			
		||||
         /*'users' => [
 | 
			
		||||
             'driver' => 'database',
 | 
			
		||||
             'table' => 'users',
 | 
			
		||||
         ],
 | 
			
		||||
         ],*/
 | 
			
		||||
    ],
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
 | 
			
		||||
@ -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();
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -18,6 +18,7 @@ class DatabaseSeeder extends Seeder
 | 
			
		||||
            UserSeeder::class,
 | 
			
		||||
            TagSeeder::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,16 +22,9 @@ class UserSeeder extends Seeder
 | 
			
		||||
                'name'=>'SystemUser',
 | 
			
		||||
                'email'=>'system@localhost.local',
 | 
			
		||||
                'password'=>Hash::make(Str::random(16)),
 | 
			
		||||
                'user_role'=>'user',
 | 
			
		||||
            ]
 | 
			
		||||
            );
 | 
			
		||||
        DB::table('users')->insert(
 | 
			
		||||
            [
 | 
			
		||||
                'name'=>'admin',
 | 
			
		||||
                'email'=>env('SYSADMIN_MAIL'),
 | 
			
		||||
                'password'=>Hash::make('admin'),
 | 
			
		||||
                'user_role'=>'admin',
 | 
			
		||||
                
 | 
			
		||||
            ]
 | 
			
		||||
            );
 | 
			
		||||
        
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,9 @@
 | 
			
		||||
<li><a href="/admin"><i class="fa fa-dashboard fa-fw"></i>Riepilogo</a>
 | 
			
		||||
</li>
 | 
			
		||||
@can('conti')
 | 
			
		||||
<li><a href="#"><i class="fa fa-money fa-fw"></i>Spese/Incassi<span
 | 
			
		||||
		class="fa arrow"></span></a>
 | 
			
		||||
 | 
			
		||||
	<ul class="nav nav-second-level">
 | 
			
		||||
		<li><a href="{{ route('movimenti'); }}">Lista Movimenti</a></li>
 | 
			
		||||
		<li><a href="{{ route('categorie'); }}">Categorie</a></li>
 | 
			
		||||
@ -17,7 +19,10 @@
 | 
			
		||||
				<li><a href="{{ route('importCR'); }}"><i
 | 
			
		||||
						class="fa fa-upload  fa-fw"></i>Importa Estratto CR</a></li>
 | 
			
		||||
			</ul></li>
 | 
			
		||||
	
 | 
			
		||||
	</ul> <!-- /.nav-second-level --></li>
 | 
			
		||||
@endcan
 | 
			
		||||
@can('consumi')
 | 
			
		||||
<li><a href="#"><i class="fa fa-industry fa-fw"></i> Consumi <span
 | 
			
		||||
		class="fa arrow"></span></a>
 | 
			
		||||
 | 
			
		||||
@ -28,8 +33,12 @@
 | 
			
		||||
		<li><a href="{{ route('enel'); }}"><i class="fa fa-flash  fa-fw"></i>Energia
 | 
			
		||||
				Elettrica</a></li>
 | 
			
		||||
	</ul></li>
 | 
			
		||||
@endcan
 | 
			
		||||
@can('automobili')
 | 
			
		||||
<li><a href="{{ route('auto_list'); }}"><i class="fa fa-car fa-fw"></i>
 | 
			
		||||
		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
 | 
			
		||||
		class="fa arrow"></span></a>
 | 
			
		||||
 | 
			
		||||
@ -40,8 +49,12 @@
 | 
			
		||||
		<li><a href="{{ route('newContact'); }}"><i class="fa fa-plus  fa-fw"></i>Nuovo
 | 
			
		||||
				contatto</a></li>
 | 
			
		||||
	</ul></li>
 | 
			
		||||
@endcan
 | 
			
		||||
@can('progetti')
 | 
			
		||||
<li><a href="{{ route('progetti'); }}"><i class="fa fa-list fa-fw"></i>
 | 
			
		||||
		Progetti <span class="fa arrow"></span></a></li>
 | 
			
		||||
@endcan
 | 
			
		||||
@can('amministrazione')
 | 
			
		||||
<li><a href="#"><i class="fa fa-gears fa-fw"></i>Amministrazione<span
 | 
			
		||||
		class="fa arrow"></span></a>
 | 
			
		||||
	<ul class="nav nav-second-level">
 | 
			
		||||
@ -52,3 +65,4 @@
 | 
			
		||||
				ai gruppi</a></li>
 | 
			
		||||
		<li><a href="/login">Login Page</a></li>
 | 
			
		||||
	</ul> <!-- /.nav-second-level --></li>
 | 
			
		||||
	@endcan
 | 
			
		||||
 | 
			
		||||
@ -7,10 +7,10 @@
 | 
			
		||||
	<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>
 | 
			
		||||
 | 
			
		||||
	@role('admin')
 | 
			
		||||
        <li class="divider"></li>
 | 
			
		||||
        <li><a href="#"><i class="fa fa-gear fa-fw"></i> Gestisci Utenti</a></li>
 | 
			
		||||
 | 
			
		||||
	@endrole
 | 
			
		||||
		<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>
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user