/** * Creates data provider instance with search query applied * @return ActiveDataProvider */ public function search($params) { $query = Emailf::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'domain_id' => $this->domain_id]); if ($this->search_date_created != '') { $this->data_begin_created = strtotime($this->search_date_created); $this->data_end_created = strtotime($this->search_date_created) + 24 * 60 * 60; } $query->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['between', 'created_at', $this->data_begin_created, $this->data_end_created]); return $dataProvider; }
/** * Creates a new About model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Feedback(); if ($model->load(Yii::$app->request->post()) && $model->save()) { $mailModel = Emailf::findAll(['status' => 1]); foreach ($mailModel as $mail) { $mails[] = $mail->email; } $mailTo = $mails; $post = Yii::$app->request->post('Feedback'); $userID = $post['domain_id']; $user = \api\models\User::findOne($userID); $subject = $post['subject']; $message = $post['text']; // die(); Yii::$app->mailer->compose('feedback-html', ['name' => $user->username, 'subject' => $subject, 'message' => $message, 'date' => time()])->setSubject(Yii::t('frontend', '{app-name} | ' . $subject, ['app-name' => Yii::$app->name]))->setTo($mailTo)->send(); return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model]); } }
protected function findModel($id) { if (($model = Emailf::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }