Files
sam-manage/database/seeders/AiTokenUsageMenuSeeder.php
김보곤 5fe6afd9c4 feat:AI 음성녹음 기능 추가
- AiVoiceRecording 모델 (상태 상수, 접근자)
- AiVoiceRecordingService (GCS 업로드, STT, Gemini 분석 파이프라인)
- AiVoiceRecordingController (CRUD, 녹음 처리, 상태 폴링)
- React 블레이드 뷰 (녹음 UI, 파일 업로드, 목록, 상세 모달)
- 라우트 추가 (system/ai-voice-recording)
- 메뉴 시더에 AI 음성녹음 항목 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 12:52:37 +09:00

126 lines
4.6 KiB
PHP

<?php
namespace Database\Seeders;
use App\Models\Commons\Menu;
use Illuminate\Database\Seeder;
class AiTokenUsageMenuSeeder extends Seeder
{
public function run(): void
{
$tenantId = 1;
// 1. AI 관리 부모 그룹 찾기 또는 생성
$aiGroup = Menu::withoutGlobalScopes()
->where('tenant_id', $tenantId)
->where('name', 'AI 관리')
->whereNull('parent_id')
->whereNull('deleted_at')
->first();
if (! $aiGroup) {
$aiGroup = Menu::withoutGlobalScopes()->create([
'tenant_id' => $tenantId,
'parent_id' => null,
'name' => 'AI 관리',
'url' => null,
'icon' => 'brain-circuit',
'sort_order' => 12,
'is_active' => true,
]);
$this->command->info("AI 관리 부모 그룹 생성 완료 (id: {$aiGroup->id})");
} else {
$this->command->info("AI 관리 부모 그룹 이미 존재 (id: {$aiGroup->id})");
}
// 2. AI 설정 메뉴를 AI 관리 그룹으로 이동 (다른 그룹에 있는 경우)
$aiConfig = Menu::withoutGlobalScopes()
->where('tenant_id', $tenantId)
->where('name', 'AI 설정')
->whereNull('deleted_at')
->first();
if ($aiConfig && $aiConfig->parent_id !== $aiGroup->id) {
$aiConfig->update([
'parent_id' => $aiGroup->id,
'sort_order' => 1,
]);
$this->command->info("AI 설정 메뉴를 AI 관리 그룹으로 이동 완료");
} elseif (! $aiConfig) {
$this->command->warn("AI 설정 메뉴가 존재하지 않습니다. (건너뜀)");
} else {
$this->command->info("AI 설정 메뉴가 이미 AI 관리 그룹에 있습니다.");
}
// 3. AI 토큰 사용량 메뉴 생성 또는 이동
$aiToken = Menu::withoutGlobalScopes()
->where('tenant_id', $tenantId)
->where('name', 'AI 토큰 사용량')
->whereNull('deleted_at')
->first();
if ($aiToken && $aiToken->parent_id !== $aiGroup->id) {
$aiToken->update([
'parent_id' => $aiGroup->id,
'sort_order' => 2,
]);
$this->command->info("AI 토큰 사용량 메뉴를 AI 관리 그룹으로 이동 완료");
} elseif (! $aiToken) {
Menu::withoutGlobalScopes()->create([
'tenant_id' => $tenantId,
'parent_id' => $aiGroup->id,
'name' => 'AI 토큰 사용량',
'url' => '/system/ai-token-usage',
'icon' => 'brain-circuit',
'sort_order' => 2,
'is_active' => true,
]);
$this->command->info("AI 토큰 사용량 메뉴 생성 완료");
} else {
$this->command->info("AI 토큰 사용량 메뉴가 이미 AI 관리 그룹에 있습니다.");
}
// 4. AI 음성녹음 메뉴 생성 또는 이동
$aiVoice = Menu::withoutGlobalScopes()
->where('tenant_id', $tenantId)
->where('name', 'AI 음성녹음')
->whereNull('deleted_at')
->first();
if ($aiVoice && $aiVoice->parent_id !== $aiGroup->id) {
$aiVoice->update([
'parent_id' => $aiGroup->id,
'sort_order' => 3,
]);
$this->command->info("AI 음성녹음 메뉴를 AI 관리 그룹으로 이동 완료");
} elseif (! $aiVoice) {
Menu::withoutGlobalScopes()->create([
'tenant_id' => $tenantId,
'parent_id' => $aiGroup->id,
'name' => 'AI 음성녹음',
'url' => '/system/ai-voice-recording',
'icon' => 'mic',
'sort_order' => 3,
'is_active' => true,
]);
$this->command->info("AI 음성녹음 메뉴 생성 완료");
} else {
$this->command->info("AI 음성녹음 메뉴가 이미 AI 관리 그룹에 있습니다.");
}
// 결과 출력
$this->command->info('');
$this->command->info('=== AI 관리 하위 메뉴 ===');
$children = Menu::withoutGlobalScopes()
->where('parent_id', $aiGroup->id)
->whereNull('deleted_at')
->orderBy('sort_order')
->get(['name', 'url', 'sort_order']);
foreach ($children as $child) {
$this->command->info("{$child->sort_order}. {$child->name} ({$child->url})");
}
}
}