Пример #1
0
 public function search($params)
 {
     $query = Artikel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => 'DESC']], 'pagination' => ['defaultPageSize' => 10]]);
     $this->load($params);
     if (!$this->validate()) {
         $query->where('1=0');
         return $dataProvider;
     }
     $dataProvider->query->joinWith(['kategori' => function ($q) {
         $q->from('artikel_kategori ak');
         // join with tabel alias
     }]);
     $query->orFilterWhere(['like', 'ak.nama', $this->srch_all]);
     // $query->andFilterWhere(['like', 'tb_group2.name', $this->parent_id]);
     // SELESAI EDIT DISINI
     /*$query->andFilterWhere([
                 'id' => $this->id,
                 'kategori_id' => $this->kategori_id,
                 'created_by' => $this->created_by,
                 'creaed_date' => $this->creaed_date,
                 'updated_by' => $this->updated_by,
                 'updated_date' => $this->updated_date,
             ]);
     */
     $query->orFilterWhere(['like', 'judul', $this->srch_all])->orFilterWhere(['like', 'isi', $this->srch_all]);
     return $dataProvider;
 }
Пример #2
0
 protected function listKomentar($id)
 {
     if (($model = Artikel::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Artikel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 4], 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'kategori_id' => $this->kategori_id, 'created_by' => $this->created_by, 'creaed_date' => $this->creaed_date, 'updated_by' => $this->updated_by, 'updated_date' => $this->updated_date]);
     $query->andFilterWhere(['like', 'judul', $this->judul])->andFilterWhere(['like', 'isi', $this->isi]);
     return $dataProvider;
 }