From 449fc474e70a7f7f5a8b4224db2d5ac54b7063b9 Mon Sep 17 00:00:00 2001 From: toogee Date: Tue, 14 Apr 2020 19:08:31 +0800 Subject: [PATCH] comment not null --- app/index/controller/Article.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php index 28bf73a..cba125e 100644 --- a/app/index/controller/Article.php +++ b/app/index/controller/Article.php @@ -152,7 +152,9 @@ class Article extends BaseController //获取评论 $data = Request::only(['content','article_id','user_id']); $sendId = $data['user_id']; - + if(empty($data['content'])){ + return json(['code'=>0, 'msg'=>'评论不能为空!']); + } //用户留言存入数据库 if (Comment::create($data)) { //站内信 @@ -184,7 +186,6 @@ class Article extends BaseController { if(Request::isAjax()){ $data = Request::only(['cate_id','title','title_color','user_id','content','upzip','tags','captcha']); - halt($data); $validate = new \app\common\validate\Article; //调用验证器 $result = $validate->scene('Artadd')->check($data); //进行数据验证 if(true !==$result){