41 lines
1.3 KiB
PHP
41 lines
1.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Requests\Approval;
|
||
|
|
|
||
|
|
use App\Models\Tenants\ApprovalForm;
|
||
|
|
use Illuminate\Foundation\Http\FormRequest;
|
||
|
|
|
||
|
|
class FormUpdateRequest extends FormRequest
|
||
|
|
{
|
||
|
|
public function authorize(): bool
|
||
|
|
{
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function rules(): array
|
||
|
|
{
|
||
|
|
$categories = implode(',', ApprovalForm::CATEGORIES);
|
||
|
|
|
||
|
|
return [
|
||
|
|
'name' => 'nullable|string|max:100',
|
||
|
|
'code' => 'nullable|string|max:50|regex:/^[a-zA-Z0-9_-]+$/',
|
||
|
|
'category' => "nullable|string|in:{$categories}",
|
||
|
|
'template' => 'nullable|array',
|
||
|
|
'template.fields' => 'required_with:template|array',
|
||
|
|
'template.fields.*.name' => 'required_with:template.fields|string|max:50',
|
||
|
|
'template.fields.*.type' => 'required_with:template.fields|string|in:text,textarea,number,date,select,checkbox,file',
|
||
|
|
'template.fields.*.label' => 'required_with:template.fields|string|max:100',
|
||
|
|
'template.fields.*.required' => 'nullable|boolean',
|
||
|
|
'template.fields.*.options' => 'nullable|array',
|
||
|
|
'is_active' => 'nullable|boolean',
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
public function messages(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'code.regex' => __('validation.regex', ['attribute' => '양식코드']),
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|