Example #1
0
 public function search($params)
 {
     $query = Agama::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([
         'parentGroup'=> function ($q){
             $q->from('tb_group tb_group2');  // join with tabel alias
         }
     ]);
          
     $query->andFilterWhere(['like', 'tb_group.name', $this->name]);
     $query->andFilterWhere(['like', 'tb_group2.name', $this->parent_id]);
     // SELESAI EDIT DISINI
     */
     $query->andFilterWhere(['status' => $this->status]);
     $query->andFilterWhere(['like', 'name', $this->srch_all]);
     return $dataProvider;
 }
Example #2
0
 protected function findModel($id)
 {
     if (($model = Agama::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #3
0
 public function listAgama()
 {
     $data = ArrayHelper::map(\backend\models\Agama::find()->where(['status' => 1])->all(), 'id', 'name');
     return $data;
 }