Link.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace app\admin\controller\greenroom;
  3. use app\common\controller\Backend;
  4. /**
  5. * Site Federation
  6. *
  7. * @icon fa fa-link
  8. */
  9. class Link extends Backend
  10. {
  11. /**
  12. * Link模型对象
  13. * @var \app\admin\model\greenroom\Link
  14. */
  15. protected $model = null;
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = new \app\admin\model\greenroom\Link;
  20. }
  21. /**
  22. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  23. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  24. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  25. */
  26. public function edit($ids = null)
  27. {
  28. if ($this->request->isPost()) {
  29. // echo "-----------";
  30. $params = $this->request->post('row/a');
  31. if (empty($params)) {
  32. $this->error(__('Parameter %s can not be empty', ''));
  33. }
  34. $params = $this->preExcludeFields($params);
  35. if (bccomp($params['minincome'], $params['maxincome'], 7) === 1) {
  36. return $this->error("最小值不允许超过最大值");
  37. }
  38. }
  39. return parent::edit($ids);
  40. }
  41. public function add()
  42. {
  43. if ($this->request->isPost()) {
  44. $params = $this->request->post('row/a');
  45. if (empty($params)) {
  46. $this->error(__('Parameter %s can not be empty', ''));
  47. }
  48. $params = $this->preExcludeFields($params);
  49. if (bccomp($params['minincome'], $params['maxincome'], 7) === 1) {
  50. return $this->error("最小值不允许超过最大值");
  51. }
  52. }
  53. return parent::add();
  54. }
  55. }