Exemple #1
0
 /**
  * Seo creation
  * @return boolean
  */
 public function create()
 {
     if (!$this->validate()) {
         return false;
     }
     $this->object = $object = new Seo(['url' => $this->url, 'title' => empty($this->title) ? null : $this->title, 'keywords' => empty($this->keywords) ? null : $this->keywords, 'description' => empty($this->description) ? null : $this->description, 'snippet' => empty($this->snippet) ? null : $this->snippet]);
     if (!$object->save(false)) {
         return false;
     }
     return true;
 }
Exemple #2
0
 /**
  * SEO deleting.
  * @param integer $id SEO id.
  * @return void
  */
 public function actionDelete($id)
 {
     $item = Seo::findOne($id);
     if ($item === null) {
         throw new BadRequestHttpException(Yii::t('seo', 'SEO not found.'));
     }
     if ($item->delete()) {
         Yii::$app->session->setFlash('success', Yii::t('seo', 'SEO deleted successfully.'));
     }
     return $this->redirect(['index']);
 }
Exemple #3
0
 /**
  * Search function.
  * @param array $params Attributes array.
  * @return yii\data\ActiveDataProvider
  */
 public function search($params)
 {
     //ActiveQuery
     $query = Seo::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     //return data provider if no search
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     //search
     $query->andFilterWhere(['like', 'url', $this->url]);
     return $dataProvider;
 }