feat: add article and production modules
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace plugin\produce\app\validate;
|
||||
|
||||
use core\base\BaseValidate;
|
||||
use Illuminate\Validation\Rule;
|
||||
use plugin\produce\app\model\StepStatus;
|
||||
|
||||
class StepStatusValidate extends BaseValidate
|
||||
{
|
||||
public function rules(): array
|
||||
{
|
||||
$id = request()->route?->param('id');
|
||||
$stepId = (string) (request()->input('step_id') ?? '');
|
||||
|
||||
return [
|
||||
'step_id' => ['required', 'integer'],
|
||||
'status_code' => [
|
||||
'required',
|
||||
'max:50',
|
||||
Rule::unique(StepStatus::class, 'status_code')
|
||||
->where(fn ($query) => $query->where('step_id', $stepId))
|
||||
->ignore($id, 'id')
|
||||
],
|
||||
'status_name' => ['required', 'max:100'],
|
||||
'is_initial' => ['nullable', 'integer', 'in:0,1'],
|
||||
'is_final' => ['nullable', 'integer', 'in:0,1'],
|
||||
'description' => ['nullable', 'max:65535'],
|
||||
'sort' => ['nullable', 'integer', 'min:0'],
|
||||
'status' => ['nullable', 'integer', 'in:0,1'],
|
||||
];
|
||||
}
|
||||
|
||||
protected array $message = [
|
||||
'step_id.required' => '所属步骤不能为空',
|
||||
'step_id.integer' => '所属步骤格式不正确',
|
||||
'status_code.required' => '状态编码不能为空',
|
||||
'status_code.max' => '状态编码不能超过50个字符',
|
||||
'status_code.unique' => '状态编码已存在',
|
||||
'status_name.required' => '状态名称不能为空',
|
||||
'status_name.max' => '状态名称不能超过100个字符',
|
||||
'is_initial.integer' => '初始状态格式不正确',
|
||||
'is_initial.in' => '初始状态值不正确',
|
||||
'is_final.integer' => '终态格式不正确',
|
||||
'is_final.in' => '终态值不正确',
|
||||
'description.max' => '状态描述内容过长',
|
||||
'sort.integer' => '排序必须为整数',
|
||||
'sort.min' => '排序不能小于0',
|
||||
'status.integer' => '状态格式不正确',
|
||||
'status.in' => '状态值不正确',
|
||||
];
|
||||
|
||||
protected array $scene = [
|
||||
'store' => ['step_id', 'status_code', 'status_name', 'is_initial', 'is_final', 'description', 'sort', 'status'],
|
||||
'update' => ['step_id', 'status_code', 'status_name', 'is_initial', 'is_final', 'description', 'sort', 'status'],
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user