-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcreate_library_item_permissions_table.php.stub
More file actions
41 lines (35 loc) · 1.21 KB
/
create_library_item_permissions_table.php.stub
File metadata and controls
41 lines (35 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('library_item_permissions', function (Blueprint $table) {
$table->id();
// Add tenant foreign key if tenancy is enabled
if (config('filament-library.tenancy.enabled')) {
$tenantModel = config('filament-library.tenancy.model');
if ($tenantModel) {
$table->foreignIdFor($tenantModel)->constrained()->cascadeOnDelete();
}
}
$table->foreignId('library_item_id')->constrained()->cascadeOnDelete();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->enum('role', ['owner', 'editor', 'viewer']);
$table->timestamps();
$table->unique(['library_item_id', 'user_id'], 'library_item_perms_unique');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('library_item_permissions');
}
};