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 @@ + + +
+ + + + field($model, 'name')->textInput(['maxlength' => true]) ?> + + field($model, 'status')->textInput() ?> + +
+ isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/frontend/views/payment/_search.php b/frontend/views/payment/_search.php new file mode 100644 index 0000000..d2c8b17 --- /dev/null +++ b/frontend/views/payment/_search.php @@ -0,0 +1,31 @@ + + + diff --git a/frontend/views/payment/create.php b/frontend/views/payment/create.php new file mode 100644 index 0000000..e86523e --- /dev/null +++ b/frontend/views/payment/create.php @@ -0,0 +1,21 @@ +title = Yii::t('app', 'Create Payment'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Payments'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/frontend/views/payment/index.php b/frontend/views/payment/index.php new file mode 100644 index 0000000..8de62b9 --- /dev/null +++ b/frontend/views/payment/index.php @@ -0,0 +1,34 @@ +title = Yii::t('app', 'Payments'); +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ render('_search', ['model' => $searchModel]); ?> + +

+ 'btn btn-success']) ?> +

+ $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'payment_id', + 'name', + 'status', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
diff --git a/frontend/views/payment/update.php b/frontend/views/payment/update.php new file mode 100644 index 0000000..16e30e5 --- /dev/null +++ b/frontend/views/payment/update.php @@ -0,0 +1,23 @@ +title = Yii::t('app', 'Update {modelClass}: ', [ + 'modelClass' => 'Payment', +]) . ' ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Payments'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->payment_id]]; +$this->params['breadcrumbs'][] = Yii::t('app', 'Update'); +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/frontend/views/payment/view.php b/frontend/views/payment/view.php new file mode 100644 index 0000000..281e6d4 --- /dev/null +++ b/frontend/views/payment/view.php @@ -0,0 +1,37 @@ +title = $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Payments'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ $model->payment_id], ['class' => 'btn btn-primary']) ?> + $model->payment_id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), + 'method' => 'post', + ], + ]) ?> +

+ + $model, + 'attributes' => [ + 'payment_id', + 'name', + 'status', + ], + ]) ?> + +
-- libgit2 0.21.4