作者 何书鹏
1 个管道 的构建 通过 耗费 2 秒

发布公告

... ... @@ -362,7 +362,9 @@ class HouseAdmin extends Api
{
$house_id = $this->request->param('house_id');
empty($house_id) && $this->error('缺少必要参数');
$count = HouseBoard::whereTime('createtime', 'week')->count();
$count = HouseBoard::whereTime('createtime', 'week')
->where('house_id',$house_id)
->count();
$times = $count >= 2 ? 0 : 2-$count;
$this->success('success',compact('times'));
}
... ... @@ -392,6 +394,10 @@ class HouseAdmin extends Api
empty($post['content']) && $this->error('请填写公告内容');
$admin = HouseAdminModel::get(['user_id'=>$this->auth->id,'house_id'=>$post['house_id']]);
empty($admin) && $this->error('您不是该小区的管理员');
$count = HouseBoard::whereTime('createtime', 'week')
->where('house_id',$post['house_id'])
->count();
$count >= 2 && $this->error('本周发布次数已用完');
(new HouseBoard)->allowField(true)->save(array_merge([
'admin_user_id' => $this->auth->id
],$post));
... ...