单独验证类, 无法使用, 类似laravel10的那种
`<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Exceptions\HttpResponseException;
class BaseRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize(): bool
{
return true;
}
/**
* @param Validator $validator
* @return void
* @throws HttpResponseException
*/
protected function failedValidation(Validator $validator) :void
{
$error = $validator->errors()->first();
$response = apiErrorJson($error);
throw new HttpResponseException($response);
}
}
`
单独验证类, 无法使用, 类似laravel10的那种
`<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Exceptions\HttpResponseException;
class BaseRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize(): bool
{
return true;
}
}
`