Exemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied.
  *
  * @param array $params Search params
  *
  * @return ActiveDataProvider DataProvider
  */
 public function search($params)
 {
     $query = self::find()->where(['model_class' => Security::crc32(PagePost::className())]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status_id' => $this->status_id, 'FROM_UNIXTIME(created_at, "%d.%m.%Y")' => $this->created_at, 'FROM_UNIXTIME(updated_at, "%d.%m.%Y")' => $this->updated_at]);
     $query->andFilterWhere(['like', 'alias', $this->alias]);
     $query->andFilterWhere(['like', 'title', $this->title]);
     $query->andFilterWhere(['like', 'snippet', $this->snippet]);
     $query->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
Exemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         $this->id = Security::crc32($this->name);
         return true;
     } else {
         return false;
     }
 }