[FormRequest 업데이트] - ProductStoreRequest, ProductUpdateRequest에 하이브리드 필드 추가 - 고정 필드: safety_stock, lead_time, is_variable_size, product_category, part_type - 동적 필드: attributes, attributes_archive - unit 필드 추가 - is_active → 제거 (모델과 일치) - boolean 검증 개선 (in:0,1 → boolean) [ProductService 업데이트] - store/update 메서드 중복 Validator 제거 (FormRequest가 검증) - 기본값 설정 간소화 (true/false로 통일) - is_active 관련 로직 주석처리 - index 메서드 필터 - toggle 메서드 비활성화 - search 메서드 select 컬럼 수정 - Validator import 제거 [ProductController 업데이트] - toggle 메서드 주석처리 (is_active 제거에 따름) [기능 변경] - 기존: 고정 필드 위주 - 변경: 하이브리드 구조 (최소 고정 + attributes JSON) - attributes를 통해 테넌트별 커스텀 필드 지원 [비고] - is_active는 필요시 attributes JSON이나 별도 필드로 재구현 가능 - toggle 기능도 필요시 복원 가능 (주석으로 보존)
43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Product;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class ProductUpdateRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
// 기본 필드
|
|
'code' => 'sometimes|string|max:30',
|
|
'name' => 'sometimes|string|max:100',
|
|
'unit' => 'nullable|string|max:10',
|
|
'category_id' => 'sometimes|integer',
|
|
'product_type' => 'sometimes|string|max:30',
|
|
'description' => 'nullable|string|max:255',
|
|
|
|
// 상태 플래그
|
|
'is_sellable' => 'nullable|boolean',
|
|
'is_purchasable' => 'nullable|boolean',
|
|
'is_producible' => 'nullable|boolean',
|
|
|
|
// 하이브리드 구조: 고정 필드
|
|
'safety_stock' => 'nullable|integer|min:0',
|
|
'lead_time' => 'nullable|integer|min:0',
|
|
'is_variable_size' => 'nullable|boolean',
|
|
'product_category' => 'nullable|string|max:20',
|
|
'part_type' => 'nullable|string|max:20',
|
|
|
|
// 하이브리드 구조: 동적 필드
|
|
'attributes' => 'nullable|array',
|
|
'attributes_archive' => 'nullable|array',
|
|
];
|
|
}
|
|
}
|