30 lines
610 B
PHP
Raw Normal View History

2018-11-29 22:44:16 +08:00
<?php
/**
* UserRequest.php
* Created by wuyanwen <wuyanwen1992@gmail.com>
* Date: 2018/11/29 0029 21:56
*/
namespace app\admin\request;
2018-11-30 18:29:35 +08:00
use think\exception\HttpResponseException;
2018-11-29 22:44:16 +08:00
use think\Request;
abstract class FormRequest extends Request
{
2018-11-30 09:56:27 +08:00
/**
* FormRequest constructor.
*/
2018-11-29 22:44:16 +08:00
public function __construct()
{
parent::__construct();
2018-11-30 09:56:27 +08:00
if ($this->withServer($_SERVER)->isAjax(true) && $err = $this->validate()) {
2018-11-30 18:29:35 +08:00
throw new HttpResponseException(json([
'code' => 0,
'msg' => $err,
'wait' => 3,
]));
2018-11-30 09:56:27 +08:00
}
2018-11-29 22:44:16 +08:00
}
}