feat(labor): 노임관리 API 구현

- Labor 모델 (BelongsToTenant, SoftDeletes)
- LaborController 7개 엔드포인트
- LaborService 비즈니스 로직
- FormRequest 4개 (Index/Store/Update/BulkDelete)
- 마이그레이션 및 라우트 등록

API: GET/POST /labor, GET/PUT/DELETE /labor/{id}, DELETE /labor/bulk, GET /labor/stats

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-01-11 23:29:32 +09:00
parent ceb7798c28
commit f59dd1b9fb
11 changed files with 703 additions and 0 deletions

67
app/Models/Labor.php Normal file
View File

@@ -0,0 +1,67 @@
<?php
namespace App\Models;
use App\Traits\BelongsToTenant;
use App\Traits\ModelTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Labor extends Model
{
use BelongsToTenant, ModelTrait, SoftDeletes;
protected $table = 'labors';
protected $fillable = [
'tenant_id',
'labor_number',
'category',
'min_m',
'max_m',
'labor_price',
'status',
'is_active',
'created_by',
'updated_by',
'deleted_by',
];
protected $casts = [
'min_m' => 'decimal:2',
'max_m' => 'decimal:2',
'labor_price' => 'integer',
'is_active' => 'boolean',
];
/**
* 상태별 필터 Scope
*/
public function scopeByStatus($query, string $status)
{
return $query->where('status', $status);
}
/**
* 구분별 필터 Scope
*/
public function scopeByCategory($query, string $category)
{
return $query->where('category', $category);
}
/**
* 검색 Scope
*/
public function scopeSearch($query, ?string $search)
{
if (empty($search)) {
return $query;
}
return $query->where(function ($q) use ($search) {
$q->where('labor_number', 'like', "%{$search}%")
->orWhere('category', 'like', "%{$search}%");
});
}
}