Пример #1
0
 public function actionView($id)
 {
     $counter = new \app\components\counter();
     $counter->hitsCounter('guide/view', $id);
     $model = TblGuides::findOne($id);
     $Attractions = TblGuides::find()->where(['cid' => $model->cid, 'published' => 1, 'langs' => $model->langs])->limit(10)->orderBy('rand()')->all();
     return $this->render('view', ['model' => $model, 'Attractions' => $Attractions]);
 }
Пример #2
0
 public function search()
 {
     $search = $this->search;
     $langs = $this->langs;
     $cid = $this->cid;
     $amphur = $this->amphur;
     $query = TblGuides::find();
     if ($search) {
         $query->where('titles LIKE :s', [':s' => "%{$search}%"]);
     }
     if ($langs) {
         $query->andWhere(['langs' => $langs]);
     }
     if ($cid) {
         $query->andWhere(['cid' => $cid]);
     }
     if ($amphur) {
         $query->andWhere(['amphur' => $amphur]);
     }
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     return $dataProvider;
 }
Пример #3
0
 public function actionDelete($id)
 {
     $model = TblGuides::findOne($id);
     $model->delete();
     return $this->redirect(['index', 'cid' => $model->cid]);
 }