1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-30 04:23:11 +03:00

Notifications: Added role receive-notifications permission

This commit is contained in:
Dan Brown
2023-07-25 17:59:04 +01:00
parent 100b28707c
commit ff2674c464
5 changed files with 59 additions and 9 deletions

View File

@ -0,0 +1,51 @@
<?php
use Carbon\Carbon;
use Illuminate\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// Create new receive-notifications permission and assign to admin role
$permissionId = DB::table('role_permissions')->insertGetId([
'name' => 'receive-notifications',
'display_name' => 'Receive & Manage Notifications',
'created_at' => Carbon::now()->toDateTimeString(),
'updated_at' => Carbon::now()->toDateTimeString(),
]);
$adminRoleId = DB::table('roles')->where('system_name', '=', 'admin')->first()->id;
DB::table('permission_role')->insert([
'role_id' => $adminRoleId,
'permission_id' => $permissionId,
]);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$permission = DB::table('role_permissions')
->where('name', '=', 'receive-notifications')
->first();
if ($permission) {
DB::table('permission_role')->where([
'permission_id' => $permission->id,
])->delete();
}
DB::table('role_permissions')
->where('name', '=', 'receive-notifications')
->delete();
}
};