Files
sam-api/app/Http/Requests/Quote/QuoteIndexRequest.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

71 lines
2.4 KiB
PHP

<?php
namespace App\Http\Requests\Quote;
use App\Http\Requests\Traits\HasPagination;
use App\Models\Quote\Quote;
use Illuminate\Foundation\Http\FormRequest;
class QuoteIndexRequest extends FormRequest
{
use HasPagination;
public function authorize(): bool
{
return true;
}
/**
* 검증 전 데이터 전처리
* - 쿼리 스트링의 "true"/"false" 문자열을 boolean으로 변환
* - size/per_page 최대값 제한
*/
protected function prepareForValidation(): void
{
// HasPagination Trait의 페이지네이션 처리
$maxSize = $this->maxSize ?? config('pagination.max_size', 100);
if ($this->has('size') && $this->input('size') > $maxSize) {
$this->merge(['size' => $maxSize]);
}
if ($this->has('with_items')) {
$this->merge([
'with_items' => filter_var($this->with_items, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE),
]);
}
if ($this->has('for_order')) {
$this->merge([
'for_order' => filter_var($this->for_order, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE),
]);
}
}
public function rules(): array
{
return [
'page' => 'nullable|integer|min:1',
'size' => 'nullable|integer|min:1',
'q' => 'nullable|string|max:100',
'quote_type' => 'nullable|in:'.implode(',', Quote::TYPES),
'status' => 'nullable|in:'.implode(',', [
Quote::STATUS_PENDING,
Quote::STATUS_DRAFT,
Quote::STATUS_SENT,
Quote::STATUS_APPROVED,
Quote::STATUS_REJECTED,
Quote::STATUS_FINALIZED,
Quote::STATUS_CONVERTED,
]),
'product_category' => 'nullable|in:'.Quote::CATEGORY_SCREEN.','.Quote::CATEGORY_STEEL,
'client_id' => 'nullable|integer',
'date_from' => 'nullable|date',
'date_to' => 'nullable|date|after_or_equal:date_from',
'sort_by' => 'nullable|in:registration_date,quote_number,client_name,total_amount,status,created_at',
'sort_order' => 'nullable|in:asc,desc',
'with_items' => 'nullable|boolean', // 수주 전환용 품목 포함 여부
'for_order' => 'nullable|boolean', // 수주 전환용: 이미 수주가 생성된 견적 제외
];
}
}