| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- namespace app\admin\controller\platform;
- use app\common\controller\Backend;
- use app\common\model\Videolist;
- use app\common\model\Platform;
- class Vplatform extends Backend
- {
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\common\model\VideoPlatform;
- // 获取短剧和平台数据(用于下拉框)
- // $videolist = Videolist::column('id,name');
- // $platforms = Platform::column('id,name');
- // $this->assign('videolist', $videolist);
- // $this->assign('platforms', $platforms);
- }
- // 列表页
- // application/admin/controller/platform/Vplatform.php
- public function index()
- {
- $this->request->filter(['strip_tags']);
- if ($this->request->isAjax()) {
- //如果发送的来源是Selectpage,则转发到Selectpage
- if ($this->request->request('keyField')) {
- return $this->selectpage();
- }
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $total = $this->model
- ->where($where)
- ->order($sort, $order)
- ->count();
- $list = $this->model
- ->where($where)
- ->with('platform,videolist')
- ->order($sort, $order)
- ->limit($offset, $limit)
- ->select();
- $result = array("total" => $total, "rows" => $list);
- return json($result);
- }
- return $this->view->fetch();
- }
- /**
- * 编辑
- */
- public function edit($ids = NULL)
- {
- $row = $this->model->get($ids);
- if (!$row)
- $this->error(__('No Results were found'));
- return parent::edit($ids);
- }
- public function add()
- {
- return parent::add();
- }
- // public function dragsort()
- // {
- // if ($this->request->isPost()) {
- // $ids = $this->request->post('ids');
- // // 根据 $ids 更新排序逻辑(示例代码)
- // foreach ($ids as $index => $id) {
- // $this->model::where('id', $id)->update(['sort' => $index + 1]);
- // }
- // $this->success();
- // }
- // $this->error(__('参数错误'));
- // }
- // // 添加
- // public function add()
- // {
- // if ($this->request->isPost()) {
- // $params = $this->request->post("row/a");
- // if ($params) {
- // $result = $this->model->save($params);
- // if ($result) $this->success();
- // $this->error(__('操作失败'));
- // }
- // $this->error(__('参数错误'));
- // }
- // return $this->view->fetch();
- // }
- //
- // // 编辑
- // public function edit($ids = null)
- // {
- // $row = $this->model->get($ids);
- // if (!$row) $this->error(__('记录不存在'));
- // if ($this->request->isPost()) {
- // $params = $this->request->post("row/a");
- // if ($params) {
- // $result = $row->save($params);
- // if ($result) $this->success();
- // $this->error(__('操作失败'));
- // }
- // $this->error(__('参数错误'));
- // }
- // $this->assign('row', $row);
- // return $this->view->fetch();
- // }
- }
|