|
|
|
|
@ -0,0 +1,43 @@
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 抢票相关菜单在「权限菜单」中新增/迁移后,若未写入 role_menu_permissions,侧栏不显示。
|
|
|
|
|
* 为 super_admin / venue_admin 补全 抢票管理 及子项的菜单权限行。
|
|
|
|
|
*/
|
|
|
|
|
return new class extends Migration
|
|
|
|
|
{
|
|
|
|
|
public function up(): void
|
|
|
|
|
{
|
|
|
|
|
if (! \Illuminate\Support\Facades\Schema::hasTable('admin_menus')
|
|
|
|
|
|| ! \Illuminate\Support\Facades\Schema::hasTable('role_menu_permissions')) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$ids = DB::table('admin_menus')
|
|
|
|
|
->whereIn('name', ['抢票管理', '抢票列表', '抢票报名', '抢票核销'])
|
|
|
|
|
->pluck('id');
|
|
|
|
|
|
|
|
|
|
if ($ids->isEmpty()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$now = now();
|
|
|
|
|
foreach (['super_admin', 'venue_admin'] as $role) {
|
|
|
|
|
foreach ($ids as $menuId) {
|
|
|
|
|
$mid = (int) $menuId;
|
|
|
|
|
DB::table('role_menu_permissions')->updateOrInsert(
|
|
|
|
|
['role' => $role, 'menu_id' => $mid],
|
|
|
|
|
['created_at' => $now, 'updated_at' => $now]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function down(): void
|
|
|
|
|
{
|
|
|
|
|
// 不撤销:避免误删手调权限
|
|
|
|
|
}
|
|
|
|
|
};
|