generated from liutk/owl-admin-base
45 lines
992 B
PHP
45 lines
992 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Http\Exceptions\HttpResponseException;
|
|
use Illuminate\Contracts\Validation\Validator;
|
|
|
|
class SettingRequest extends FormRequest
|
|
{
|
|
/**
|
|
* 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 [
|
|
'key' => 'required|string|max:100',
|
|
];
|
|
}
|
|
|
|
public function messages(){
|
|
$message = [
|
|
'key.required' => 'key必填',
|
|
];
|
|
return $message;
|
|
}
|
|
|
|
protected function failedValidation(Validator $validator){
|
|
$error = $validator->errors()->all();
|
|
throw new HttpResponseException(response()->json(['data' => null, 'code' => 400, 'message' => $error[0]]));
|
|
}
|
|
}
|