<?php
namespace app\store\controller\apps\sharing;
use app\store\controller\Controller;
use app\store\model\sharing\Comment as CommentModel;
class Comment extends Controller
{
public function index()
{
$model = new CommentModel;
$list = $model->getList();
return $this->fetch('index', compact('list'));
}
public function detail($comment_id)
{
$model = CommentModel::detail($comment_id);
if (!$this->request->isAjax()) {
return $this->fetch('detail', compact('model'));
}
if ($model->edit($this->postData('comment'))) {
return $this->renderSuccess('更新成功', url('apps.sharing.comment/index'));
}
return $this->renderError($model->getError() ?: '更新失败');
}
public function delete($comment_id)
{
$model = CommentModel::get($comment_id);
if (!$model->setDelete()) {
return $this->renderError('删除失败');
}
return $this->renderSuccess('删除成功');
}
}