feat(시공사): 2.1 현장관리 - Backend API 확장

- 마이그레이션: site_code, client_id, status 컬럼 추가
- Site 모델: 상태 상수, Client 관계 추가
- SiteService: stats(), bulkDestroy(), 필터 확장
- SiteController: stats, bulkDestroy 엔드포인트 추가
- 라우트: /stats, /bulk 추가

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-01-09 16:34:59 +09:00
parent 7897ad0479
commit 00f57ce244
5 changed files with 204 additions and 3 deletions

View File

@@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('sites', function (Blueprint $table) {
// 현장코드
$table->string('site_code', 50)->nullable()->after('tenant_id')->comment('현장코드');
// 거래처 연결 (clients 테이블)
$table->foreignId('client_id')->nullable()->after('site_code')
->constrained('clients')->nullOnDelete()->comment('거래처 ID');
// 상태 (is_active와 별개)
$table->enum('status', ['unregistered', 'suspended', 'active', 'pending'])
->default('unregistered')->after('is_active')->comment('상태: 미등록/중지/사용/보류');
// 인덱스
$table->index(['tenant_id', 'site_code']);
$table->index(['tenant_id', 'status']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('sites', function (Blueprint $table) {
$table->dropIndex(['tenant_id', 'site_code']);
$table->dropIndex(['tenant_id', 'status']);
$table->dropForeign(['client_id']);
$table->dropColumn(['site_code', 'client_id', 'status']);
});
}
};