/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = SmsTemplate::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
 private function getTemplate($template_id)
 {
     return SmsTemplate::find()->where(["id" => $template_id])->select("content")->scalar();
 }
 private function getViewData()
 {
     $levels = AlarmLevel::find()->where(['not', ['id' => 255]])->select(["id", "text" => "desc"])->asArray()->all();
     $categorys = AlarmCategory::find()->select(["id", "text" => "subDesc"])->asArray()->all();
     $users = ArrayHelper::map(User::find()->select(["id", "username"])->all(), 'id', 'username');
     $templates = SmsTemplate::find()->select(["id", "name"])->asArray()->all();
     $templates = ArrayHelper::map($templates, 'id', 'name');
     return ["levels" => $levels, "categorys" => $categorys, "users" => $users, "templates" => $templates];
 }