no message
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\validate\community;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\community\CommunityComment;
|
||||
|
||||
class CommunityCommentValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkComment',
|
||||
'status' => 'require|in:0,1',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '评论id不能为空',
|
||||
'status.require' => '状态不能为空',
|
||||
];
|
||||
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneStatus()
|
||||
{
|
||||
return $this->only(['id', 'status']);
|
||||
}
|
||||
|
||||
public function checkComment($value)
|
||||
{
|
||||
$comment = CommunityComment::findOrEmpty($value);
|
||||
if ($comment->isEmpty()) {
|
||||
return '评论不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\validate\community;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\community\CommunityPost;
|
||||
|
||||
class CommunityPostValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkPost',
|
||||
'status' => 'require|in:0,1,2',
|
||||
'is_top' => 'require|in:0,1',
|
||||
'is_hot' => 'require|in:0,1',
|
||||
'is_recommend' => 'require|in:0,1',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '帖子id不能为空',
|
||||
'status.require' => '状态不能为空',
|
||||
];
|
||||
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneStatus()
|
||||
{
|
||||
return $this->only(['id', 'status']);
|
||||
}
|
||||
|
||||
public function sceneTop()
|
||||
{
|
||||
return $this->only(['id', 'is_top']);
|
||||
}
|
||||
|
||||
public function sceneHot()
|
||||
{
|
||||
return $this->only(['id', 'is_hot']);
|
||||
}
|
||||
|
||||
public function sceneRecommend()
|
||||
{
|
||||
return $this->only(['id', 'is_recommend']);
|
||||
}
|
||||
|
||||
public function checkPost($value)
|
||||
{
|
||||
$post = CommunityPost::findOrEmpty($value);
|
||||
if ($post->isEmpty()) {
|
||||
return '帖子不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\validate\community;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\community\CommunityTag;
|
||||
|
||||
class CommunityTagValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkTag',
|
||||
'name' => 'require|length:1,50',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '标签id不能为空',
|
||||
'name.require' => '标签名称不能为空',
|
||||
'name.length' => '标签名称长度须在1-50位字符',
|
||||
];
|
||||
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', 'require|checkTag');
|
||||
}
|
||||
|
||||
public function sceneEdit()
|
||||
{
|
||||
}
|
||||
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkTag($value)
|
||||
{
|
||||
$tag = CommunityTag::findOrEmpty($value);
|
||||
if ($tag->isEmpty()) {
|
||||
return '标签不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user