You've already forked guangan
点赞及详情
This commit is contained in:
@ -23,14 +23,8 @@ class Thumb extends Controller
|
|||||||
if (empty($thumb)) {
|
if (empty($thumb)) {
|
||||||
$this->error('点赞城市不存在');
|
$this->error('点赞城市不存在');
|
||||||
}
|
}
|
||||||
CmsThumb::mk()->scope('published')->where('id', $id)->inc("view_count");
|
$thumb->inc("view_count");
|
||||||
|
$thumb->save();
|
||||||
$this->success('获取点赞城市详情', $thumb);
|
$this->success('获取点赞城市详情', $thumb);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function like()
|
|
||||||
{
|
|
||||||
$id = $this->request->post('id');
|
|
||||||
CmsThumb::mk()->scope('published')->where('id', $id)->inc("like_count");
|
|
||||||
$this->success('点赞成功');
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -43,10 +43,27 @@ class Thumb extends Auth
|
|||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
$id = $this->request->get('id');
|
$id = $this->request->get('id');
|
||||||
$thumb = CmsThumb::mk()->scope('published')->where('user_id', '=', $this->usid)->where('id', $id)->find();
|
$thumb = CmsThumb::mk()->scope('published')->where('id', $id)->find();
|
||||||
if (empty($thumb)) {
|
if (empty($thumb)) {
|
||||||
$this->error('点赞城市不存在');
|
$this->error('点赞城市不存在');
|
||||||
}
|
}
|
||||||
$this->success('获取点赞城市成功', $thumb);
|
$thumb->inc("view_count");
|
||||||
|
$thumb->save();
|
||||||
|
$this->success('获取点赞城市详情', $thumb);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function like()
|
||||||
|
{
|
||||||
|
$id = $this->request->post('id');
|
||||||
|
$thumb = CmsThumb::mk()->scope('published')->where('id', $id)->find();
|
||||||
|
if (empty($thumb)) {
|
||||||
|
$this->error('点赞城市不存在');
|
||||||
|
}
|
||||||
|
$like = $thumb->like()->save([
|
||||||
|
'user_id' => $this->usid
|
||||||
|
]);
|
||||||
|
$thumb->inc("like_count");
|
||||||
|
$thumb->save();
|
||||||
|
$this->success('点赞成功');
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user