42 lines
1.0 KiB
PHP
42 lines
1.0 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
return new class extends Migration
|
|
{
|
|
public function up(): void
|
|
{
|
|
$permissions = [
|
|
'holding.view',
|
|
'holding.create',
|
|
'holding.update',
|
|
'holding.delete',
|
|
'holding.assignments.manage',
|
|
'holding.context.switch',
|
|
];
|
|
|
|
$now = now()->toDateTimeString();
|
|
foreach ($permissions as $permission) {
|
|
DB::table('permissions')->updateOrInsert(
|
|
['name' => $permission, 'guard_name' => 'web'],
|
|
['updated_at' => $now, 'created_at' => $now]
|
|
);
|
|
}
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
DB::table('permissions')
|
|
->whereIn('name', [
|
|
'holding.view',
|
|
'holding.create',
|
|
'holding.update',
|
|
'holding.delete',
|
|
'holding.assignments.manage',
|
|
'holding.context.switch',
|
|
])
|
|
->delete();
|
|
}
|
|
};
|