| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\admin\models;
- use yii\base\Model;
- use yii\helpers\Json;
- /**
- * @property \app\models\MailSetting $list;
- */
- class MailForm extends Model
- {
- public $store_id;
- public $list;
- public $send_mail;
- public $send_pwd;
- public $send_name;
- public $receive_mail;
- public $status;
- public function rules()
- {
- return [
- [['send_mail','send_pwd','send_name','receive_mail'],'required','on'=>'SUCCESS'],
- [['send_mail','send_pwd','send_name','receive_mail'],'trim'],
- [['send_mail','send_pwd','send_name','receive_mail'],'string'],
- [['status'],'in','range'=>[0,1]],
- ];
- }
- public function save()
- {
- if (!$this->validate()) {
- return [
- 'code' => 1,
- 'msg' => $this->getErrorSummary(false)[0],
- ];
- }
- if ($this->list->isNewRecord) {
- $this->list->is_delete = 0;
- $this->list->store_id = $this->store_id;
- $this->list->created_at = time();
- }
- $this->list->send_mail = $this->send_mail;
- $this->list->send_pwd = $this->send_pwd;
- $this->list->send_name = $this->send_name;
- $this->receive_mail = str_replace(',', ',', $this->receive_mail);
- $this->list->receive_mail = $this->receive_mail;
- $this->list->status = $this->status;
- if ($this->list->save()) {
- return [
- 'code'=>0,
- 'msg'=>'成功'
- ];
- } else {
- foreach ($this->list->errors as $error) {
- return [
- 'code' => 1,
- 'msg' => $error
- ];
- }
- }
- }
- }
|