62 lines
1.3 KiB
PHP
62 lines
1.3 KiB
PHP
<?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;
|
|
}
|
|
}
|