first version
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Customer;
|
||||
|
||||
use Modules\Common\Http\Requests\BaseFormRequest;
|
||||
|
||||
/**
|
||||
* 通知 创建 验证(user_id 留空 = 全员广播)
|
||||
*/
|
||||
class NoticeFormRequest extends BaseFormRequest
|
||||
{
|
||||
protected $stopOnFirstFailure = true;
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge(['user_id' => (int) ($this->input('user_id') ?? 0)]);
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => 'required|integer|min:0',
|
||||
'type' => 'required|string|in:order,price,system',
|
||||
'title' => 'required|string|max:100',
|
||||
'content' => 'nullable|string|max:500',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'type.required' => '通知类型不能为空',
|
||||
'type.in' => '通知类型只能是 order/price/system',
|
||||
'title.required' => '通知标题不能为空',
|
||||
'title.max' => '通知标题最长 100 个字符',
|
||||
'content.max' => '通知内容最长 500 个字符',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user