/** * Updates an existing Hoadon model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $list = Khachhang::find()->all(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect('http://localhost/basic/web/index.php?r=hoadon%2Findex'); } else { return $this->render('update', ['model' => $model, 'list' => $list]); } }
public function actionDelete($id) { $user = Khachhang::findOne($id); if (!empty($user)) { $user->status = 0; if ($user->save()) { return $this->redirect('?r=khachhang/index'); } } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Khachhang::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id_khachhang' => $this->id_khachhang, 'record_status' => $this->record_status]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'phone', $this->phone]); return $dataProvider; }
/** * Finds the Khachhang model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Khachhang the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Khachhang::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getIdKhachhang() { return $this->hasOne(Khachhang::className(), ['id_khachhang' => 'id_khachhang']); }
public function actionPreview($id) { $model = Khachhang::findOne($id); return $this->render('preview', ['model' => $model]); }
/** * @return \yii\db\ActiveQuery */ public function getKhachhang() { return $this->hasOne(Khachhang::className(), ['khachhang_id' => 'khachhang_id']); }