<?php
namespace app\store\controller\wxapp;
use app\store\controller\Controller;
use app\store\model\WxappHelp as WxappHelpModel;
class Help extends Controller
{
public function index()
{
$model = new WxappHelpModel;
$list = $model->getList();
return $this->fetch('index', compact('list'));
}
public function add()
{
$model = new WxappHelpModel;
if (!$this->request->isAjax()) {
return $this->fetch('add');
}
if ($model->add($this->postData('help'))) {
return $this->renderSuccess('添加成功', url('wxapp.help/index'));
}
return $this->renderError($model->getError() ?: '添加失败');
}
public function edit($help_id)
{
$model = WxappHelpModel::detail($help_id);
if (!$this->request->isAjax()) {
return $this->fetch('edit', compact('model'));
}
if ($model->edit($this->postData('help'))) {
return $this->renderSuccess('更新成功', url('wxapp.help/index'));
}
return $this->renderError($model->getError() ?: '更新失败');
}
public function delete($help_id)
{
$model = WxappHelpModel::detail($help_id);
if (!$model->remove()) {
return $this->renderError($model->getError() ?: '删除失败');
}
return $this->renderSuccess('删除成功');
}
}