Files
sam-manage/app/Models/VideoGeneration.php
김보곤 3f4cd88c20 feat:영상 파일 GCS 저장 및 삭제 연동
- VideoGenerationJob: 최종 합성 후 GCS 업로드, gcs_path 저장
- Veo3Controller: download/preview GCS 서명URL 사용, destroy GCS 파일 삭제
- VideoGeneration 모델: gcs_path fillable 추가
- GCS 불가 시 로컬 파일로 폴백

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 11:11:18 +09:00

87 lines
1.8 KiB
PHP

<?php
namespace App\Models;
use App\Models\Scopes\TenantScope;
use Illuminate\Database\Eloquent\Model;
class VideoGeneration extends Model
{
protected $fillable = [
'tenant_id',
'user_id',
'keyword',
'title',
'scenario',
'status',
'progress',
'current_step',
'clips_data',
'output_path',
'gcs_path',
'cost_usd',
'error_message',
];
protected $casts = [
'scenario' => 'array',
'clips_data' => 'array',
'progress' => 'integer',
'cost_usd' => 'decimal:4',
];
protected static function booted(): void
{
static::addGlobalScope(new TenantScope);
}
public function user()
{
return $this->belongsTo(\App\Models\User::class);
}
/**
* 상태 상수
*/
const STATUS_PENDING = 'pending';
const STATUS_TITLES_GENERATED = 'titles_generated';
const STATUS_SCENARIO_READY = 'scenario_ready';
const STATUS_GENERATING_TTS = 'generating_tts';
const STATUS_GENERATING_CLIPS = 'generating_clips';
const STATUS_GENERATING_BGM = 'generating_bgm';
const STATUS_ASSEMBLING = 'assembling';
const STATUS_COMPLETED = 'completed';
const STATUS_FAILED = 'failed';
/**
* 진행 상태 업데이트 헬퍼
*/
public function updateProgress(string $status, int $progress, string $step): void
{
$this->update([
'status' => $status,
'progress' => $progress,
'current_step' => $step,
]);
}
/**
* 실패 처리
*/
public function markFailed(string $errorMessage): void
{
$this->update([
'status' => self::STATUS_FAILED,
'error_message' => $errorMessage,
]);
}
}