12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace app\admin\controller\community;
- use app\common\controller\Backend;
- use think\Exception;
- use think\exception\DbException;
- use think\response\Json;
- /**
- * 下载地址管理
- *
- * @icon fa fa-circle-o
- */
- class Downloadlink extends Backend
- {
- /**
- * DownloadLink模型对象
- * @var \app\common\model\DownloadLink
- */
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\common\model\DownloadLink;
- }
- /**
- * 查看
- *
- * @return string|Json
- * @throws \think\Exception
- * @throws DbException
- */
- public function index()
- {
- if ($this->request->isPost()) {
- $row = $this->request->post("row/a");
- if(count($row) == 2){
- $alteration = ['name','image'];
- }else{
- $alteration = ['name','image','content'];
- }
- $res = array_combine($alteration,$row);
- try {
- $this->model->save($res,['name'=>$res['name']]);
- } catch (Exception $e) {
- $this->error($e->getMessage());
- }
- $this->success("提交成功", null, ['data' => json_encode($this->request->post("row/a"), JSON_UNESCAPED_UNICODE)]);
- }else{
- if (false === $this->request->isAjax()) {
- $this->assign('iantern_slide',$this->model->get(['name'=>'下载地址']));
- return $this->view->fetch();
- }
- }
- }
- }
|