Files
sam-api/app/Models/Labor.php
권혁성 7246ac003f fix(WEB): 수주 페이지 필드 매핑 및 제품-부품 트리 구조 개선
- ApiClient 인터페이스: representative → manager_name, contact_person 변경
- transformApiToFrontend: client.representative → client.manager_name 수정
- ApiOrderItem에 floor_code, symbol_code 필드 추가 (제품-부품 매핑)
- ApiOrder에 options 타입 정의 추가
- ApiQuote에 calculation_inputs 타입 정의 추가
- 수주 상세 페이지 제품-부품 트리 구조 UI 개선
2026-01-20 16:14:46 +09:00

68 lines
1.4 KiB
PHP

<?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}%");
});
}
}