public function actionSave() { $model = Text::find()->where(['slug' => \Yii::$app->request->post('attr')])->one(); $model->text = \Yii::$app->request->post('data'); \Yii::$app->cache->flush(); return $model->save(); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Text::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, 'status' => $this->status]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'subtitle', $this->subtitle])->andFilterWhere(['like', 'layout', $this->layout])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'text', $this->text]); return $dataProvider; }
private function findText($id_slug, $id) { if ($id) { $return = \app\modules\text\models\Text::find()->where(['status' => 1, 'id' => $id_slug])->all(); } else { $return = isset($this->_texts[$id_slug . '_' . \Yii::$app->language]) ? $this->_texts[$id_slug . '_' . \Yii::$app->language] : null; } return $return; }