| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace app\admin\controller;
- use app\BaseController;
- use app\common\model\SupplierModel;
- use think\App;
- use think\facade\View;
- use think\Request;
- class Supplier extends BaseController
- {
- private $model;
- public function __construct(App $app)
- {
- $this->model = new SupplierModel();
- parent::__construct($app);
- }
- public function index() {
- View::assign([
- "list" => $this->model->findByPaginate($this->request->param())
- ]);
- return view();
- }
- public function add() {
- $params = $this->request->param();
- if ($this->request->isAjax()) {
- $res = $this->model->save([
- 'name' => $params['name'],
- 'introduce' => $params['introduce']
- ]);
- return $res ? $this->ok(true) : $this->fail(false);
- }
- return view();
- }
- public function edit() {
- $params = $this->request->param();
- $supplier = $this->model->findById($params['id']);
- if($this->request->isAjax()) {
- $res = $this->model->where('id', $params['id'])->update([
- 'name' => $params['name'],
- 'introduce' => $params['introduce'],
- 'update_time' => time()
- ]);
- return $res ? $this->ok(true) : $this->fail(false);
- }
- View::assign('supplier',$supplier);
- return view();
- }
- public function delete(Request $request) {
- $params = $request->param();
- if(!isset($params['ids']))
- return $this->fail(lang("Please select the data you want to delete"));
- $this->model->deleteByIds(explode(',', $params['ids']));
- return $this->ok(true);
- }
- }
|