feat: [leaves] 휴가-결재 연동을 위한 DB 변경

- leaves 테이블에 approval_id 컬럼 추가 (마이그레이션)
- 휴가신청 결재 양식(approval_forms) 등록 (마이그레이션)
- Leave 모델 fillable에 approval_id 추가
This commit is contained in:
김보곤
2026-02-28 15:54:34 +09:00
parent bfb821698a
commit 1d2876d90c
3 changed files with 65 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('leaves', function (Blueprint $table) {
$table->unsignedBigInteger('approval_id')->nullable()->after('status')->comment('연결된 결재 문서 ID');
$table->index('approval_id');
});
}
public function down(): void
{
Schema::table('leaves', function (Blueprint $table) {
$table->dropIndex(['approval_id']);
$table->dropColumn('approval_id');
});
}
};

View File

@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
public function up(): void
{
// tenant_id=1 에 휴가신청 결재 양식 등록 (이미 존재하면 무시)
DB::table('approval_forms')->insertOrIgnore([
'tenant_id' => 1,
'name' => '휴가신청',
'code' => 'leave',
'category' => 'request',
'template' => json_encode([
'fields' => [
['name' => 'user_name', 'type' => 'text', 'label' => '신청자'],
['name' => 'leave_type', 'type' => 'text', 'label' => '휴가유형'],
['name' => 'period', 'type' => 'text', 'label' => '기간'],
['name' => 'days', 'type' => 'number', 'label' => '일수'],
['name' => 'reason', 'type' => 'text', 'label' => '사유'],
['name' => 'remaining_days', 'type' => 'text', 'label' => '잔여연차'],
],
], JSON_UNESCAPED_UNICODE),
'is_active' => true,
'created_by' => 1,
'created_at' => now(),
'updated_at' => now(),
]);
}
public function down(): void
{
DB::table('approval_forms')
->where('tenant_id', 1)
->where('code', 'leave')
->delete();
}
};