- quotes 테이블에 quote_type 컬럼 추가 (manufacturing/construction) - Quote 모델에 TYPE 상수 및 스코프 메서드 추가 - QuoteService.index()에 quote_type 필터 적용 - QuoteService.upsertFromSiteBriefing()에 construction 타입 설정 - QuoteIndexRequest에 quote_type 유효성 검증 추가 - 기존 site_briefing_id 있는 데이터는 construction으로 자동 업데이트 Co-Authored-By: Claude <noreply@anthropic.com>
54 lines
1.7 KiB
PHP
54 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Quote;
|
|
|
|
use App\Models\Quote\Quote;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class QuoteIndexRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* 검증 전 데이터 전처리
|
|
* - 쿼리 스트링의 "true"/"false" 문자열을 boolean으로 변환
|
|
*/
|
|
protected function prepareForValidation(): void
|
|
{
|
|
if ($this->has('with_items')) {
|
|
$this->merge([
|
|
'with_items' => filter_var($this->with_items, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE),
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'page' => 'nullable|integer|min:1',
|
|
'size' => 'nullable|integer|min:1|max:100',
|
|
'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', // 수주 전환용 품목 포함 여부
|
|
];
|
|
}
|
|
}
|