love_php/app/Http/Requests/StoreGeneralQrcode.php

55 lines
1.4 KiB
PHP
Raw Permalink Normal View History

2026-04-02 09:20:51 +08:00
<?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 StoreGeneralQrcode 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 [
'title' => 'required|max:50',
'jump_url' => 'required|max:255|url',
'remark' => 'nullable|max:255',
];
}
public function messages()
{
return [
'title.required' => '请输入标题',
'title.max' => '标题超出最大字数',
'jump_url.required' => '请输入跳转链接',
'jump_url.url' => '请输入正确的跳转链接',
'jump_url.max' => '跳转链接超出最大长度',
'remark.max' => '备注超出最大字数',
];
}
public function failedValidation(Validator $validator)
{
$msg = $validator->errors()->first();
throw new HttpResponseException($this->failure($msg));
}
}