当前位置: 首页>>代码示例>>PHP>>正文


PHP Setting::findOne方法代码示例

本文整理汇总了PHP中app\models\Setting::findOne方法的典型用法代码示例。如果您正苦于以下问题:PHP Setting::findOne方法的具体用法?PHP Setting::findOne怎么用?PHP Setting::findOne使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Setting的用法示例。


在下文中一共展示了Setting::findOne方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionSendChat

 public function actionSendChat()
 {
     if (!empty($_POST)) {
         echo \sintret\chat\ChatRoom::sendChat($_POST);
         $message = Yii::$app->user->identity->username . ' : ' . $_POST['message'];
         $pos = strpos($message, "@");
         $setting = \app\models\Setting::findOne(1);
         if ($pos !== FALSE) {
             // $w = new WhatsApp($number, $app, $password);
             $usernameSendgrid = $setting->sendgridUsername;
             $passwordSendgrid = $setting->sendgridPassword;
             $users = \app\models\User::find()->where(['status' => \app\models\User::STATUS_ACTIVE])->all();
             foreach ($users as $model) {
                 $aprot = '@' . strtolower($model->username);
                 if (strpos($message, $aprot) !== false) {
                     $sendgrid = new \SendGrid($usernameSendgrid, $passwordSendgrid, array("turn_off_ssl_verification" => true));
                     $email = new \SendGrid\Email();
                     $email->addTo($model->email)->setFrom($setting->emailSupport)->setSubject('Chat from ' . $setting->applicationName)->setHtml($message);
                     $sendgrid->send($email);
                 } else {
                 }
             }
         }
     }
 }
开发者ID:sintret,项目名称:yii2-basic-sintret,代码行数:25,代码来源:AjaxController.php

示例2: findModel

 protected function findModel($id)
 {
     if (($model = Setting::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:sindotnet,项目名称:cona,代码行数:8,代码来源:SettingController.php

示例3: init

 public function init()
 {
     if ($this->setting = Setting::findOne($this->getSettingKey())) {
         $this->load(Json::decode($this->setting->svalue), '');
     } else {
         $this->setting = new Setting();
     }
 }
开发者ID:rusli-nasir,项目名称:yii2-php-ci,代码行数:8,代码来源:PhpLoc.php

示例4: actionIndex

 public function actionIndex()
 {
     if (Yii::$app->user->isGuest) {
         $this->redirect(Yii::$app->urlManager->createAbsoluteUrl('site/login'));
     }
     $view = 'index';
     return $this->render($view, ['settings' => \app\models\Setting::findOne(1)]);
 }
开发者ID:sintret,项目名称:yii2-basic-sintret,代码行数:8,代码来源:SiteController.php

示例5: actionIndex

 public function actionIndex()
 {
     $setting = Setting::findOne(1);
     if ($setting->load(Yii::$app->request->post()) && $setting->save()) {
         return $this->redirect(['/']);
     }
     return $this->render('index', ['setting' => $setting]);
 }
开发者ID:hoangngk,项目名称:adminpanel,代码行数:8,代码来源:SettingsController.php

示例6: sendEmail

 /**
  * Sends an email with a link, for resetting the password.
  *
  * @return boolean whether the email was send
  */
 public function sendEmail()
 {
     /* @var $user User */
     $user = User::findOne(['status' => User::STATUS_ACTIVE, 'email' => $this->email]);
     if ($user) {
         if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
             $user->generatePasswordResetToken();
         }
         if ($user->save()) {
             $setting = Setting::findOne(1);
             return \Yii::$app->mailer->compose('passwordResetToken', ['user' => $user])->setFrom([$setting->emailAdmin => \Yii::$app->name . ' robot'])->setTo($this->email)->setSubject('Password reset for ' . \Yii::$app->name)->send();
         }
     }
     return false;
 }
开发者ID:sintret,项目名称:yii2-basic,代码行数:20,代码来源:PasswordResetRequestForm.php

示例7: settings

 public static function settings()
 {
     $model = \app\models\Setting::findOne(1);
     return $model;
 }
开发者ID:sintret,项目名称:yii2-basic-sintret,代码行数:5,代码来源:Util.php

示例8: actionParsingLog

 public function actionParsingLog($id)
 {
     $mod = LogUpload::findOne($id);
     $type = $mod->type;
     $keys = \yii\helpers\Json::decode($mod->keys);
     $values = \yii\helpers\Json::decode($mod->values);
     $modelAttribute = new Setting();
     $not = Util::excelNot();
     foreach ($values as $value) {
         if ($type == LogUpload::TYPE_INSERT) {
             $model = new Setting();
         } else {
             $model = Setting::findOne($value['id']);
         }
         foreach ($keys as $v) {
             $model->{$v} = $value[$v];
         }
         $e = 0;
         if ($model->save()) {
             $model = NULL;
             $pos = NULL;
         } else {
             $error[] = \yii\helpers\Json::encode($model->getErrors());
             $e = 1;
         }
     }
     if ($error) {
         foreach ($error as $err) {
             if ($err) {
                 $er[] = $err;
                 $e += 1;
             }
         }
         if ($e) {
             $mod->warning = \yii\helpers\Json::encode($er);
             $mod->save();
             echo '<pre>';
             print_r($er);
         }
     }
 }
开发者ID:sintret,项目名称:yii2-basic-sintret,代码行数:41,代码来源:SettingController.php

示例9: actionParsingLog

 public function actionParsingLog($id)
 {
     $mod = LogUpload::findOne($id);
     $type = $mod->type;
     $params = \yii\helpers\Json::decode($mod->params);
     $values = \yii\helpers\Json::decode($mod->values);
     $modelAttribute = new Setting();
     $not = Util::excelNot();
     foreach ($modelAttribute->attributeLabels() as $k => $v) {
         if (!in_array($k, $not)) {
             $attr[] = $k;
         }
     }
     foreach ($values as $value) {
         if ($type == LogUpload::TYPE_INSERT) {
             $model = new Setting();
         } else {
             $model = Setting::findOne($value['id']);
         }
         foreach ($attr as $at) {
             if (isset($value[$at])) {
                 if ($value[$at]) {
                     $model->{$at} = trim($value[$at]);
                 }
             }
         }
         $e = 0;
         if ($model->save()) {
             $model = NULL;
             $pos = NULL;
         } else {
             $error[] = \yii\helpers\Json::encode($model->getErrors());
             $e = 1;
         }
     }
     if ($error) {
         foreach ($error as $err) {
             if ($err) {
                 $er[] = $err;
                 $e += 1;
             }
         }
         if ($e) {
             $mod->warning = \yii\helpers\Json::encode($er);
             $mod->save();
             echo '<pre>';
             print_r($er);
         }
     }
 }
开发者ID:sintret,项目名称:yii2-basic,代码行数:50,代码来源:SettingController.php

示例10: ruleAction

 public static function ruleAction($id, $data)
 {
     Yii::info('$id: ' . $id, 'rule');
     Yii::info('$data: ' . $data, 'rule');
     $model = Setting::findOne($id);
     $model->data = (string) $data;
     if (!$model->save()) {
         print_r($model->errors);
         return false;
     }
     return true;
 }
开发者ID:hvos234,项目名称:raspberrypi.home.website,代码行数:12,代码来源:Setting.php


注:本文中的app\models\Setting::findOne方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。