51 lines
1.7 KiB
PHP
51 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Modules\Runner\Http\Requests;
|
|
|
|
use Illuminate\Validation\Rule;
|
|
use Modules\Common\Http\Requests\BaseFormRequest;
|
|
|
|
class RunnerApplicationFormRequest extends BaseFormRequest
|
|
{
|
|
protected $stopOnFirstFailure = true;
|
|
|
|
public function rules(): array
|
|
{
|
|
if (!$this->isUpdate()) {
|
|
return [
|
|
'user_id' => 'required|integer|exists:user,id',
|
|
'real_name' => 'required|string|max:30',
|
|
'mobile' => 'required|string|max:20',
|
|
'resume' => 'nullable|string|max:500',
|
|
'id_card' => 'required|string|size:18',
|
|
'id_card_front' => 'nullable|string|max:255',
|
|
'id_card_back' => 'nullable|string|max:255',
|
|
'status' => 'nullable|integer|in:0,1,2',
|
|
'review_remark' => 'nullable|string|max:255',
|
|
];
|
|
}
|
|
|
|
$id = $this->route('id');
|
|
return [
|
|
'user_id' => 'required|integer|exists:user,id',
|
|
'real_name' => 'required|string|max:30',
|
|
'mobile' => 'required|string|max:20',
|
|
'resume' => 'nullable|string|max:500',
|
|
'id_card' => ['required', 'string', 'size:18', Rule::unique('runner_applications', 'id_card')->ignore($id)],
|
|
'id_card_front' => 'nullable|string|max:255',
|
|
'id_card_back' => 'nullable|string|max:255',
|
|
'status' => 'nullable|integer|in:0,1,2',
|
|
'review_remark' => 'nullable|string|max:255',
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'real_name.required' => '真实姓名不能为空',
|
|
'mobile.required' => '联系电话不能为空',
|
|
'id_card.required' => '身份证号不能为空',
|
|
];
|
|
}
|
|
}
|