Vplatform.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. namespace app\admin\controller\platform;
  3. use app\common\controller\Backend;
  4. use app\common\model\Videolist;
  5. use app\common\model\Platform;
  6. class Vplatform extends Backend
  7. {
  8. protected $model = null;
  9. public function _initialize()
  10. {
  11. parent::_initialize();
  12. $this->model = new \app\common\model\VideoPlatform;
  13. // 获取短剧和平台数据(用于下拉框)
  14. // $videolist = Videolist::column('id,name');
  15. // $platforms = Platform::column('id,name');
  16. // $this->assign('videolist', $videolist);
  17. // $this->assign('platforms', $platforms);
  18. }
  19. // 列表页
  20. // application/admin/controller/platform/Vplatform.php
  21. public function index()
  22. {
  23. $this->request->filter(['strip_tags']);
  24. if ($this->request->isAjax()) {
  25. //如果发送的来源是Selectpage,则转发到Selectpage
  26. if ($this->request->request('keyField')) {
  27. return $this->selectpage();
  28. }
  29. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  30. $total = $this->model
  31. ->where($where)
  32. ->order($sort, $order)
  33. ->count();
  34. $list = $this->model
  35. ->where($where)
  36. ->with('platform,videolist')
  37. ->order($sort, $order)
  38. ->limit($offset, $limit)
  39. ->select();
  40. $result = array("total" => $total, "rows" => $list);
  41. return json($result);
  42. }
  43. return $this->view->fetch();
  44. }
  45. /**
  46. * 编辑
  47. */
  48. public function edit($ids = NULL)
  49. {
  50. $row = $this->model->get($ids);
  51. if (!$row)
  52. $this->error(__('No Results were found'));
  53. return parent::edit($ids);
  54. }
  55. public function add()
  56. {
  57. return parent::add();
  58. }
  59. // public function dragsort()
  60. // {
  61. // if ($this->request->isPost()) {
  62. // $ids = $this->request->post('ids');
  63. // // 根据 $ids 更新排序逻辑(示例代码)
  64. // foreach ($ids as $index => $id) {
  65. // $this->model::where('id', $id)->update(['sort' => $index + 1]);
  66. // }
  67. // $this->success();
  68. // }
  69. // $this->error(__('参数错误'));
  70. // }
  71. // // 添加
  72. // public function add()
  73. // {
  74. // if ($this->request->isPost()) {
  75. // $params = $this->request->post("row/a");
  76. // if ($params) {
  77. // $result = $this->model->save($params);
  78. // if ($result) $this->success();
  79. // $this->error(__('操作失败'));
  80. // }
  81. // $this->error(__('参数错误'));
  82. // }
  83. // return $this->view->fetch();
  84. // }
  85. //
  86. // // 编辑
  87. // public function edit($ids = null)
  88. // {
  89. // $row = $this->model->get($ids);
  90. // if (!$row) $this->error(__('记录不存在'));
  91. // if ($this->request->isPost()) {
  92. // $params = $this->request->post("row/a");
  93. // if ($params) {
  94. // $result = $row->save($params);
  95. // if ($result) $this->success();
  96. // $this->error(__('操作失败'));
  97. // }
  98. // $this->error(__('参数错误'));
  99. // }
  100. // $this->assign('row', $row);
  101. // return $this->view->fetch();
  102. // }
  103. }