Example #1
0
 public function search($params)
 {
     $query = Penyakit::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(['penyakitJenis' => function ($q) {
         $q->from('penyakit_jenis pj');
         // join with tabel alias
     }]);
     $query->andFilterWhere(['penyakit.status' => $this->status]);
     $query->orFilterWhere(['like', 'nama_penyakit', $this->srch_all])->orFilterWhere(['like', 'ket', $this->srch_all])->orFilterWhere(['like', 'pj.nama_jenis', $this->srch_all]);
     return $dataProvider;
 }
Example #2
0
 public function listPenyakit()
 {
     $data = ArrayHelper::map(\app\models\Penyakit::find()->where(['status' => 1])->all(), 'id', 'nama_penyakit');
     return $data;
 }
Example #3
0
 protected function findModel($id)
 {
     if (($model = Penyakit::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPenyakits()
 {
     return $this->hasMany(Penyakit::className(), ['penyakit_jenis_id' => 'id']);
 }