44 lines
1.5 KiB
PHP
44 lines
1.5 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Requests\Approval;
|
||
|
|
|
||
|
|
use App\Models\Tenants\ApprovalLine;
|
||
|
|
use Illuminate\Foundation\Http\FormRequest;
|
||
|
|
|
||
|
|
class StoreRequest extends FormRequest
|
||
|
|
{
|
||
|
|
public function authorize(): bool
|
||
|
|
{
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function rules(): array
|
||
|
|
{
|
||
|
|
$stepTypes = implode(',', ApprovalLine::STEP_TYPES);
|
||
|
|
|
||
|
|
return [
|
||
|
|
'form_id' => 'required|integer|exists:approval_forms,id',
|
||
|
|
'title' => 'required|string|max:200',
|
||
|
|
'content' => 'required|array',
|
||
|
|
'attachments' => 'nullable|array',
|
||
|
|
'attachments.*' => 'integer|exists:files,id',
|
||
|
|
'submit' => 'nullable|boolean',
|
||
|
|
'steps' => 'required_if:submit,true|array|min:1',
|
||
|
|
'steps.*.type' => "required_with:steps|string|in:{$stepTypes}",
|
||
|
|
'steps.*.user_id' => 'required_with:steps|integer|exists:users,id',
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
public function messages(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'form_id.required' => __('validation.required', ['attribute' => '결재양식']),
|
||
|
|
'form_id.exists' => __('validation.exists', ['attribute' => '결재양식']),
|
||
|
|
'title.required' => __('validation.required', ['attribute' => '제목']),
|
||
|
|
'content.required' => __('validation.required', ['attribute' => '내용']),
|
||
|
|
'steps.required_if' => __('error.approval.steps_required'),
|
||
|
|
'steps.min' => __('validation.min.array', ['attribute' => '결재단계', 'min' => 1]),
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|