ExpressDelivery.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace app\admin\controller\mall;
  3. use app\common\command\Tree;
  4. use app\common\controller\AdminController;
  5. use EasyAdmin\annotation\ControllerAnnotation;
  6. use EasyAdmin\annotation\NodeAnotation;
  7. use think\App;
  8. use think\facade\Db;
  9. /**
  10. * @ControllerAnnotation(title="express_delivery")
  11. */
  12. class ExpressDelivery extends AdminController
  13. {
  14. use \app\admin\traits\Curd;
  15. public function __construct (App $app)
  16. {
  17. parent::__construct($app);
  18. $this->model = new \app\common\model\ExpressDelivery();
  19. }
  20. public function add ()
  21. {
  22. if ($this->request->isAjax()) {
  23. $data = $this->request->post();
  24. return $this->model->saveExpress($data);
  25. }
  26. return $this->fetch();
  27. }
  28. public function edit ($id)
  29. {
  30. $data = $this->model->where(['id' => $id])->findOrEmpty()->toArray();
  31. $items = Db::name('express_shipping_method')->where(['template_id' => $data['id']])->select()->toArray();
  32. $this->assign('data', $data);
  33. $this->assign('items', $items);
  34. if ($this->request->isAjax()) {
  35. $data = $this->request->post();
  36. return $this->model->saveExpress($data);
  37. }
  38. return $this->fetch();
  39. }
  40. }