| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\admin\models\imageSearch;
- use app\models\Option;
- use yii\base\Model;
- class ImageSearchSettingFrom extends Model
- {
- public $secretId;
- public $secretKey;
- public $region;
- public $status;
- public $storeId;
- public function rules()
- {
- return [
- [['secretId','secretKey','region'],'string'],
- [['secretId','secretKey','region'],'required'],
- ['status','default','value'=>0],
- [['storeId'], 'safe'],
- ];
- }
-
- public function afterValidate() {
- if(!isset($this->storeId)){
- $this->storeId = get_store_id();
- }
- }
- public function attributes()
- {
- return [
- 'secretId' => '腾讯云账号',
- 'secretKey' => '腾讯云密钥',
- 'region' => '区域',
- 'status' => '是否允许商城使用'
- ];
- }
- public function save(){
- if(!$this->validate()){
- return [
- 'code' => 1,
- "msg" => $this->getErrorSummary(false)[0]
- ];
- }
- $setting = [
- 'secretId' => $this->secretId,
- 'secretKey' => $this->secretKey,
- 'region' => $this->region
- ];
- Option::set('tencent_image_setting',json_encode($setting), $this->storeId ,'saas');
- Option::set('tencent_image_setting_status',$this->status, $this->storeId ,'saas');
- return ['code'=>0,'msg'=>'保存成功', 'storeId' => $this->storeId];
- }
- }
|