| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace app\admin\controller;
- use app\BaseController;
- use app\common\model\CompanyModel;
- use think\App;
- use think\facade\View;
- use think\Request;
- class Company extends BaseController
- {
- private $model;
- public function __construct(App $app)
- {
- $this->model = new CompanyModel();
- 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();
- $company = $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('company', $company);
- 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);
- }
- }
|