本文整理汇总了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 {
}
}
}
}
}
示例2: findModel
protected function findModel($id)
{
if (($model = Setting::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
示例3: init
public function init()
{
if ($this->setting = Setting::findOne($this->getSettingKey())) {
$this->load(Json::decode($this->setting->svalue), '');
} else {
$this->setting = new Setting();
}
}
示例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)]);
}
示例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]);
}
示例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;
}
示例7: settings
public static function settings()
{
$model = \app\models\Setting::findOne(1);
return $model;
}
示例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);
}
}
}
示例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);
}
}
}
示例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;
}