55 lines
1.4 KiB
PHP
55 lines
1.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Requests;
|
||
|
|
|
||
|
|
use App\Http\Response\ResponseJson;
|
||
|
|
use Illuminate\Contracts\Validation\Validator;
|
||
|
|
use Illuminate\Foundation\Http\FormRequest;
|
||
|
|
use Illuminate\Http\Exceptions\HttpResponseException;
|
||
|
|
|
||
|
|
class StoreMerchantBlacklist extends FormRequest
|
||
|
|
{
|
||
|
|
use ResponseJson;
|
||
|
|
/**
|
||
|
|
* Determine if the user is authorized to make this request.
|
||
|
|
*
|
||
|
|
* @return bool
|
||
|
|
*/
|
||
|
|
public function authorize()
|
||
|
|
{
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the validation rules that apply to the request.
|
||
|
|
*
|
||
|
|
* @return array
|
||
|
|
*/
|
||
|
|
public function rules()
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'user_id' => "required|numeric",
|
||
|
|
'type' => "required|in:activity",
|
||
|
|
'reason' => "required|max:255",
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
public function messages()
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'user_id.required' => "请选择用户",
|
||
|
|
'user_id.numeric' => "用户信息错误",
|
||
|
|
'type.required' => "请选择类型",
|
||
|
|
'type.in' => "类型信息错误",
|
||
|
|
'reason.required' => "请输入黑名单理由",
|
||
|
|
'reason.max' => "黑名单理由超过最大字数",
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
public function failedValidation(Validator $validator)
|
||
|
|
{
|
||
|
|
$msg = $validator->errors()->first();
|
||
|
|
throw new HttpResponseException($this->failure($msg));
|
||
|
|
}
|
||
|
|
}
|