/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Payment::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $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, 'user_id' => $this->user_id, 'student_id' => $this->student_id, 'amount' => $this->amount, 'date' => $this->date, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); return $dataProvider; }
/** * Finds the Payment model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Payment the loaded model * @throws HttpException if the model cannot be found */ protected function findModel($id) { if (($model = Payment::findOne($id)) !== null) { return $model; } else { throw new HttpException(404, 'The requested page does not exist.'); } }
public function actionUpdatePayment($paymentId) { $payment = Payment::findOne($paymentId); if (!isset($payment)) { throw new HttpException(404, 'The requested page does not exist.'); } if ($payment->load(Yii::$app->request->post()) && $payment->save()) { Yii::$app->session->setFlash('info', "Payment updated successfully"); return $this->redirect(['default/list-payments']); } return $this->render('update-payment', compact('payment')); }
/** * @return \yii\db\ActiveQuery */ public function getPayments() { return $this->hasMany(\common\models\Payment::className(), ['created_by' => 'id']); }
public function actionUninstall() { $code = \yii::$app->request->get('code'); if (empty($code)) { UtilD::toJavaScriptAlert(\yii::t('app', 'invalid_parameter'), 'back'); \yii::$app->end(); } $sta = Payment::uninstall($code); if ($sta) { AdminLog::admin_log($code, 'uninstall', 'payment'); } $this->redirect('/payment/list'); }