1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace plugin\ali_sms\controller;
- use laytp\controller\Backend;
- use plugin\ali_sms\model\AliSms;
- /**
- * 邮件管理
- */
- class Index extends Backend
- {
- /**
- * email模型对象
- * @var \plugin\email\model\Email
- */
- protected $model;
- protected $hasSoftDel=1;//是否拥有删除功能
- public function _initialize()
- {
- $this->model = new AliSms();
- }
-
- //设置状态
- public function setStatus()
- {
- $id = $this->request->post('id');
- $fieldVal = $this->request->post('field_val');
- $isRecycle = $this->request->post('is_recycle');
- $update['status'] = $fieldVal;
- try {
- if($isRecycle) {
- $updateRes = $this->model->onlyTrashed()->where('id', '=', $id)->update($update);
- } else {
- $updateRes = $this->model->where('id', '=', $id)->update($update);
- }
- if ($updateRes) {
- return $this->success('操作成功');
- } else if ($updateRes === 0) {
- return $this->success('未作修改');
- } else {
- return $this->error('操作失败');
- }
- } catch (\Exception $e) {
- return $this->error('数据库异常,操作失败');
- }
- }
- }
|