id(); $table->string('slug')->unique(); $table->string('description')->nullable(); $table->timestamps(); }); // PermissionMember Schema::create(config('roles.table_names.permission_members'), function (Blueprint $table) { $table->id(); $table->foreignId('permission_id')->constrained('permissions')->onDelete('cascade'); $table->morphs('member'); $table->json('context')->nullable(); $table->timestamp('expires_at')->nullable(); $table->timestamps(); }); // PermissionUsage Schema::create(config('roles.table_names.permission_usage'), function (Blueprint $table) { $table->id(); $table->foreignId('permission_id')->constrained('permissions')->onDelete('cascade'); $table->float('usage', 8)->default(1); $table->morphs('user'); $table->json('context')->nullable(); $table->timestamps(); }); // Role Schema::create(config('roles.table_names.roles'), function (Blueprint $table) { $table->id(); $table->foreignId('parent_id') ->nullable() ->constrained('roles') ->onDelete('set null'); $table->string('name')->nullable(); $table->string('slug')->unique(); $table->string('description')->nullable(); $table->timestamps(); }); // RoleMember Schema::create(config('roles.table_names.role_member'), function (Blueprint $table) { $table->id(); $table->foreignId('role_id')->constrained('roles')->onDelete('cascade'); $table->morphs('member'); $table->json('context')->nullable(); $table->timestamp('expires_at')->nullable(); $table->timestamps(); }); // RolePermission Schema::create(config('roles.table_names.role_permission'), function (Blueprint $table) { $table->id(); $table->foreignId('role_id')->constrained('roles')->onDelete('cascade'); $table->foreignId('permission_id')->constrained('permissions')->onDelete('cascade'); $table->json('context')->nullable(); $table->timestamp('expires_at')->nullable(); $table->timestamps(); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists(config('roles.table_names.role_permission')); Schema::dropIfExists(config('roles.table_names.role_members')); Schema::dropIfExists(config('roles.table_names.roles')); Schema::dropIfExists(config('roles.table_names.permission_usage')); Schema::dropIfExists(config('roles.table_names.permission_members')); Schema::dropIfExists(config('roles.table_names.permissions')); } };