| 123456789101112131415161718192021222324252627282930313233 |
- <?php
- use Illuminate\Database\Migrations\Migration;
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Support\Facades\Schema;
- return new class extends Migration
- {
- /**
- * Run the migrations.
- */
- // Индивидуальные разрешения/запреты на конкретные действия для пользователя.
- // action = 'allow' перекрывает ограничения роли; 'deny' — перекрывает разрешения роли.
- public function up(): void
- {
- Schema::create('user_permissions', function (Blueprint $table) {
- $table->id();
- $table->foreignId('user_id')->constrained()->cascadeOnDelete();
- $table->string('permission'); // ключ: 'cars.edit', 'pages.view' и т.д.
- $table->enum('action', ['allow', 'deny'])->default('allow');
- $table->timestamps();
- $table->unique(['user_id', 'permission']);
- });
- }
- /**
- * Reverse the migrations.
- */
- public function down(): void
- {
- Schema::dropIfExists('user_permissions');
- }
- };
|