diff --git a/common/models/Payment.php b/common/models/Payment.php new file mode 100644 index 0000000..abdeb56 --- /dev/null +++ b/common/models/Payment.php @@ -0,0 +1,57 @@ + 255], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'payment_id' => Yii::t('app', 'Payment ID'), + 'name' => Yii::t('app', 'Name'), + 'status' => Yii::t('app', 'Status'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getUserPayments() + { + return $this->hasMany(UserPayment::className(), ['payment_id' => 'payment_id']); + } +} diff --git a/common/models/PaymentSearch.php b/common/models/PaymentSearch.php new file mode 100644 index 0000000..2f7f5ce --- /dev/null +++ b/common/models/PaymentSearch.php @@ -0,0 +1,70 @@ + $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; + } + + // grid filtering conditions + $query->andFilterWhere([ + 'payment_id' => $this->payment_id, + 'status' => $this->status, + ]); + + $query->andFilterWhere(['like', 'name', $this->name]); + + return $dataProvider; + } +} diff --git a/common/models/UserPayment.php b/common/models/UserPayment.php new file mode 100644 index 0000000..6bf96aa --- /dev/null +++ b/common/models/UserPayment.php @@ -0,0 +1,56 @@ + true, 'targetClass' => Payment::className(), 'targetAttribute' => ['payment_id' => 'payment_id']], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'user_payment_id' => Yii::t('app', 'User Payment ID'), + 'user_id' => Yii::t('app', 'User ID'), + 'payment_id' => Yii::t('app', 'Payment ID'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getPayment() + { + return $this->hasOne(Payment::className(), ['payment_id' => 'payment_id']); + } +} diff --git a/common/models/UserSpecialization.php b/common/models/UserSpecialization.php new file mode 100644 index 0000000..8fa7d75 --- /dev/null +++ b/common/models/UserSpecialization.php @@ -0,0 +1,56 @@ + true, 'targetClass' => Specialization::className(), 'targetAttribute' => ['specialization_id' => 'specialization_id']], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'user_specialization_id' => Yii::t('app', 'User Specialization ID'), + 'user_id' => Yii::t('app', 'User ID'), + 'specialization_id' => Yii::t('app', 'Specialization ID'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getSpecialization() + { + return $this->hasOne(Specialization::className(), ['specialization_id' => 'specialization_id']); + } +} diff --git a/frontend/controllers/PaymentController.php b/frontend/controllers/PaymentController.php new file mode 100644 index 0000000..097e136 --- /dev/null +++ b/frontend/controllers/PaymentController.php @@ -0,0 +1,124 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all Payment models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new PaymentSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Payment model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Payment model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Payment(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->payment_id]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Payment 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); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->payment_id]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Payment model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * 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 NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Payment::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/frontend/views/payment/_form.php b/frontend/views/payment/_form.php new file mode 100644 index 0000000..28e2a0e --- /dev/null +++ b/frontend/views/payment/_form.php @@ -0,0 +1,25 @@ + + +
+ = Html::a(Yii::t('app', 'Create Payment'), ['create'], ['class' => 'btn btn-success']) ?> +
+ = GridView::widget([ + 'dataProvider' => $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'payment_id', + 'name', + 'status', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> ++ = Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->payment_id], ['class' => 'btn btn-primary']) ?> + = Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->payment_id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), + 'method' => 'post', + ], + ]) ?> +
+ + = DetailView::widget([ + 'model' => $model, + 'attributes' => [ + 'payment_id', + 'name', + 'status', + ], + ]) ?> + +