Files
sam-api/app/Services/TenantBootstrap/Steps/MenusStep.php

29 lines
936 B
PHP

<?php
namespace App\Services\TenantBootstrap\Steps;
use App\Services\TenantBootstrap\Contracts\TenantBootstrapStep;
use Illuminate\Support\Facades\DB;
class MenusStep implements TenantBootstrapStep
{
public function key(): string { return 'menus_seed'; }
public function run(int $tenantId): void
{
// 예시: menus 테이블이 있다고 가정한 최소 스텁 (스키마에 맞춰 수정)
if (!DB::getSchemaBuilder()->hasTable('menus')) return;
$exists = DB::table('menus')->where(['tenant_id'=>$tenantId, 'code'=>'ROOT'])->exists();
if (!$exists) {
DB::table('menus')->insert([
'tenant_id'=>$tenantId,
'name'=>'메인',
'parent_id'=>null, 'sort_order'=>0,
'is_active'=>1, 'created_at'=>now(), 'updated_at'=>now(),
]);
// 필요 시 하위 기본 메뉴들 추가…
}
}
}