Files
sam-manage/app/Http/Requests/UpdateEquipmentRequest.php
김보곤 05845b5311 fix: [equipment] 담당자 → 관리자 정/부 라벨 변경 및 sub_manager_id 저장 버그 수정
- 설비 등록/수정 폼 라벨: 정 담당자 → 관리자 정, 부 담당자 → 관리자 부
- 상세보기(basic-info) 라벨 동일 변경
- StoreEquipmentRequest, UpdateEquipmentRequest에 sub_manager_id 검증 규칙 추가
- 기존에 sub_manager_id가 validated()에서 누락되어 저장되지 않던 버그 수정
2026-02-28 16:03:00 +09:00

58 lines
1.8 KiB
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class UpdateEquipmentRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
$tenantId = session('selected_tenant_id', 1);
$id = $this->route('id');
return [
'equipment_code' => [
'required', 'string', 'max:20',
Rule::unique('equipments', 'equipment_code')
->where('tenant_id', $tenantId)
->ignore($id),
],
'name' => 'required|string|max:100',
'equipment_type' => 'nullable|string|max:50',
'specification' => 'nullable|string|max:255',
'manufacturer' => 'nullable|string|max:100',
'model_name' => 'nullable|string|max:100',
'serial_no' => 'nullable|string|max:100',
'location' => 'nullable|string|max:100',
'production_line' => 'nullable|string|max:50',
'purchase_date' => 'nullable|date',
'install_date' => 'nullable|date',
'purchase_price' => 'nullable|numeric|min:0',
'useful_life' => 'nullable|integer|min:0',
'status' => 'nullable|in:active,idle,disposed',
'disposed_date' => 'nullable|date',
'manager_id' => 'nullable|exists:users,id',
'sub_manager_id' => 'nullable|exists:users,id',
'photo_path' => 'nullable|string|max:500',
'memo' => 'nullable|string',
'is_active' => 'nullable|boolean',
'sort_order' => 'nullable|integer|min:0',
];
}
public function attributes(): array
{
return [
'equipment_code' => '설비코드',
'name' => '설비명',
];
}
}