StoryLangs.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace app\admin\controller\story;
  3. use app\common\controller\Backend;
  4. /**
  5. * 创业故事多语言信息管理
  6. *
  7. * @icon fa fa-circle-o
  8. */
  9. class StoryLangs extends Backend
  10. {
  11. /**
  12. * StoryLangs模型对象
  13. * @var \app\admin\model\story\StoryLangs
  14. */
  15. protected $model = null;
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = new \app\admin\model\story\StoryLangs;
  20. $this->view->assign("langlistList", $this->model->getLanglistList());
  21. }
  22. public function import()
  23. {
  24. parent::import();
  25. }
  26. /**
  27. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  28. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  29. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  30. */
  31. /**
  32. * 添加
  33. */
  34. public function add()
  35. {
  36. if ($this->request->isPost()) {
  37. $params = $this->request->post("row/a");
  38. if ($this->model->where('story_id', $params['story_id'])->where('langlist', $params['langlist'])->find()) {
  39. $this->error(__('Same Language Data'));
  40. }
  41. }
  42. return parent::add();
  43. }
  44. /**
  45. * 添加
  46. */
  47. public function edit($ids = null)
  48. {
  49. if ($this->request->isPost()) {
  50. $params = $this->request->post("row/a");
  51. if ($this->model->where('id', '<>', $ids)->where('story_id', $params['story_id'])->where('langlist', $params['langlist'])->find()) {
  52. $this->error(__('Same Language Data'));
  53. }
  54. }
  55. return parent::edit($ids);
  56. }
  57. }