Files
sam-api/app/Http/Requests/Approval/SubmitRequest.php

40 lines
1.3 KiB
PHP
Raw Normal View History

<?php
namespace App\Http\Requests\Approval;
use App\Models\Tenants\ApprovalLine;
use Illuminate\Foundation\Http\FormRequest;
class SubmitRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
$stepTypes = implode(',', ApprovalLine::STEP_TYPES);
return [
// steps는 optional - 없으면 기존 결재선 사용
'steps' => 'nullable|array',
'steps.*.type' => "nullable|string|in:{$stepTypes}",
'steps.*.step_type' => "nullable|string|in:{$stepTypes}",
'steps.*.user_id' => 'nullable|integer|exists:users,id',
'steps.*.approver_id' => 'nullable|integer|exists:users,id',
'steps.*.step_order' => 'nullable|integer|min:1',
];
}
public function messages(): array
{
return [
'steps.*.type.in' => __('validation.in', ['attribute' => '단계유형']),
'steps.*.step_type.in' => __('validation.in', ['attribute' => '단계유형']),
'steps.*.user_id.exists' => __('validation.exists', ['attribute' => '결재자']),
'steps.*.approver_id.exists' => __('validation.exists', ['attribute' => '결재자']),
];
}
}