/**
  * Sends an email to the application administrators using the information collected by this model.
  * @return boolean whether the model passes validation
  */
 public function send()
 {
     if ($this->validate()) {
         foreach (Admin::find()->all() as $admin) {
             /* @var $admin Admin */
             Yii::$app->mailer->compose('contact', ['form' => $this, 'admin' => $admin])->setTo($admin->email)->setFrom([Yii::$app->params['appEmail'] => Yii::$app->name])->setSubject(Yii::t('help', '{appName} Contact Inquiry: {subject}', ['appName' => Yii::$app->name, 'subject' => $this->subject]))->send();
         }
         return true;
     }
     return false;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Admin::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         $query->where('0=1');
         return $dataProvider;
     }
     // status
     if (empty($this->statusId)) {
         $query->andFilterWhere(['not', ['statusId' => Admin::STATUS_DELETED]]);
     } elseif ($this->statusId > 0) {
         $query->andFilterWhere(['statusId' => $this->statusId]);
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'createdAt' => $this->createdAt, 'updatedAt' => $this->updatedAt]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'authKey', $this->authKey]);
     return $dataProvider;
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAdmin()
 {
     return $this->hasOne(Admin::className(), ['id' => 'adminId']);
 }