diff --git a/config/db.php b/config/db.php index c4c1252..42106e5 100644 --- a/config/db.php +++ b/config/db.php @@ -2,8 +2,8 @@ return [ 'class' => 'yii\db\Connection', - 'dsn' => 'mysql:host=localhost;dbname=yii2basic', + 'dsn' => 'mysql:host=localhost;dbname=univer_yii', 'username' => 'root', - 'password' => '', + 'password' => 'qqq', 'charset' => 'utf8', ]; diff --git a/config/web.php b/config/web.php index 9a23983..34f49cc 100644 --- a/config/web.php +++ b/config/web.php @@ -4,6 +4,7 @@ $config = [ 'id' => 'basic', + 'language' => 'ru-RU', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'components' => [ @@ -45,6 +46,13 @@ ], ], ], + // my module for home work ln8 geekhub phpAdvance + // module: create - crud, db - migrations + 'modules' => [ + 'homework' => [ + 'class' => 'app\modules\homework\Module', + ], + ], 'params' => $params, ]; diff --git a/controllers/AppController.php b/controllers/AppController.php new file mode 100644 index 0000000..f61946f --- /dev/null +++ b/controllers/AppController.php @@ -0,0 +1,10 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all Department models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new DepartmentSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Department model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Department model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Department(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing University 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->id]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing University 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 University model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Department the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Department::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} \ No newline at end of file diff --git a/controllers/StudentController.php b/controllers/StudentController.php new file mode 100644 index 0000000..0c8c3cd --- /dev/null +++ b/controllers/StudentController.php @@ -0,0 +1,120 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all Student models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new StudentSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Student model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Student model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Student(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Student 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->id]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Student 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 Student model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Student the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Student::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} \ No newline at end of file diff --git a/controllers/TeacherController.php b/controllers/TeacherController.php new file mode 100644 index 0000000..942df6c --- /dev/null +++ b/controllers/TeacherController.php @@ -0,0 +1,120 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all Teacher models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new TeacherSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Teacher model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Teacher model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Teacher(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Teacher 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->id]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Teacher 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 Teacher model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Teacher the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Teacher::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} \ No newline at end of file diff --git a/controllers/UniversityController.php b/controllers/UniversityController.php new file mode 100644 index 0000000..e506225 --- /dev/null +++ b/controllers/UniversityController.php @@ -0,0 +1,120 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all University models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new UniversitySearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single University model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new University model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new University(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing University 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->id]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing University 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 University model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return University the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = University::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} \ No newline at end of file diff --git a/migrations/m161203_155259_create_university_table.php b/migrations/m161203_155259_create_university_table.php new file mode 100644 index 0000000..96a4d0b --- /dev/null +++ b/migrations/m161203_155259_create_university_table.php @@ -0,0 +1,27 @@ +createTable('university', [ + 'id' => $this->primaryKey(), + ]); + } + + /** + * @inheritdoc + */ + public function down() + { + $this->dropTable('university'); + } +} diff --git a/migrations/m161203_155345_add_university_name_column_to_university_table.php b/migrations/m161203_155345_add_university_name_column_to_university_table.php new file mode 100644 index 0000000..fe2008a --- /dev/null +++ b/migrations/m161203_155345_add_university_name_column_to_university_table.php @@ -0,0 +1,25 @@ +addColumn('university', 'university_name', $this->string()); + } + + /** + * @inheritdoc + */ + public function down() + { + $this->dropColumn('university', 'university_name'); + } +} diff --git a/migrations/m161203_155421_create_department_table.php b/migrations/m161203_155421_create_department_table.php new file mode 100644 index 0000000..8344272 --- /dev/null +++ b/migrations/m161203_155421_create_department_table.php @@ -0,0 +1,61 @@ +createTable('department', [ + 'id' => $this->primaryKey(), + 'university_id' => $this->integer()->notNull(), + 'department_name' => $this->string(), + ]); + + // creates index for column `university_id` + $this->createIndex( + 'idx-department-university_id', + 'department', + 'university_id' + ); + + // add foreign key for table `university` + $this->addForeignKey( + 'fk-department-university_id', + 'department', + 'university_id', + 'university', + 'id', + 'CASCADE' + ); + } + + /** + * @inheritdoc + */ + public function down() + { + // drops foreign key for table `university` + $this->dropForeignKey( + 'fk-department-university_id', + 'department' + ); + + // drops index for column `university_id` + $this->dropIndex( + 'idx-department-university_id', + 'department' + ); + + $this->dropTable('department'); + } +} diff --git a/migrations/m161204_201453_create_teacher_table.php b/migrations/m161204_201453_create_teacher_table.php new file mode 100644 index 0000000..3b225be --- /dev/null +++ b/migrations/m161204_201453_create_teacher_table.php @@ -0,0 +1,28 @@ +createTable('teacher', [ + 'id' => $this->primaryKey(), + 'teacher_name' => $this->string(80) + ]); + } + + /** + * @inheritdoc + */ + public function down() + { + $this->dropTable('teacher'); + } +} diff --git a/migrations/m161204_201645_create_student_table.php b/migrations/m161204_201645_create_student_table.php new file mode 100644 index 0000000..f5da182 --- /dev/null +++ b/migrations/m161204_201645_create_student_table.php @@ -0,0 +1,28 @@ +createTable('student', [ + 'id' => $this->primaryKey(), + 'student_name' => $this->string(80) + ]); + } + + /** + * @inheritdoc + */ + public function down() + { + $this->dropTable('student'); + } +} diff --git a/migrations/m161204_202545_create_junction_table_for_teacher_and_student_tables.php b/migrations/m161204_202545_create_junction_table_for_teacher_and_student_tables.php new file mode 100644 index 0000000..36a538b --- /dev/null +++ b/migrations/m161204_202545_create_junction_table_for_teacher_and_student_tables.php @@ -0,0 +1,91 @@ +createTable('teacher_student', [ + 'teacher_id' => $this->integer(), + 'student_id' => $this->integer(), + 'PRIMARY KEY(teacher_id, student_id)', + ]); + + // creates index for column `teacher_id` + $this->createIndex( + 'idx-teacher_student-teacher_id', + 'teacher_student', + 'teacher_id' + ); + + // add foreign key for table `teacher` + $this->addForeignKey( + 'fk-teacher_student-teacher_id', + 'teacher_student', + 'teacher_id', + 'teacher', + 'id', + 'CASCADE' + ); + + // creates index for column `student_id` + $this->createIndex( + 'idx-teacher_student-student_id', + 'teacher_student', + 'student_id' + ); + + // add foreign key for table `student` + $this->addForeignKey( + 'fk-teacher_student-student_id', + 'teacher_student', + 'student_id', + 'student', + 'id', + 'CASCADE' + ); + } + + /** + * @inheritdoc + */ + public function down() + { + // drops foreign key for table `teacher` + $this->dropForeignKey( + 'fk-teacher_student-teacher_id', + 'teacher_student' + ); + + // drops index for column `teacher_id` + $this->dropIndex( + 'idx-teacher_student-teacher_id', + 'teacher_student' + ); + + // drops foreign key for table `student` + $this->dropForeignKey( + 'fk-teacher_student-student_id', + 'teacher_student' + ); + + // drops index for column `student_id` + $this->dropIndex( + 'idx-teacher_student-student_id', + 'teacher_student' + ); + + $this->dropTable('teacher_student'); + } +} diff --git a/models/Department.php b/models/Department.php new file mode 100644 index 0000000..a9f283d --- /dev/null +++ b/models/Department.php @@ -0,0 +1,59 @@ + 'ID', + 'department_name' => 'Department Name', + 'university_id' => 'University Id', + ]; + } + + /** + * relation Many-to-One: many Department, One Univer + * @return \yii\db\ActiveQuery + */ + public function getUniversity() + { + return $this->hasOne(University::className(), ['id' => 'university_id']); + } +} \ No newline at end of file diff --git a/models/DepartmentSearch.php b/models/DepartmentSearch.php new file mode 100644 index 0000000..c3f8378 --- /dev/null +++ b/models/DepartmentSearch.php @@ -0,0 +1,67 @@ + $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([ + 'id' => $this->id, + ]); + + $query->andFilterWhere(['like', 'department_name', $this->department_name]) + ->andFilterWhere(['like', 'university_id', $this->university_id]); + + return $dataProvider; + } +} \ No newline at end of file diff --git a/models/Student.php b/models/Student.php new file mode 100644 index 0000000..ddbaaa5 --- /dev/null +++ b/models/Student.php @@ -0,0 +1,58 @@ + 'ID', + 'student_name' => 'Student Name', + ]; + } + + /** + * relation Many-to-Many: many Student - many Teacher + * @return \yii\db\ActiveQuery + */ + public function getTeachers() + { + return $this->hasMany(Teacher::className(), ['id' => 'teacher_id']) + ->viaTable('teacher_student', ['student_id' => 'id']); + } +} \ No newline at end of file diff --git a/models/StudentSearch.php b/models/StudentSearch.php new file mode 100644 index 0000000..bba164c --- /dev/null +++ b/models/StudentSearch.php @@ -0,0 +1,66 @@ + $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([ + 'id' => $this->id, + ]); + + $query->andFilterWhere(['like', 'student_name', $this->student_name]); + + return $dataProvider; + } +} \ No newline at end of file diff --git a/models/Teacher.php b/models/Teacher.php new file mode 100644 index 0000000..6172faa --- /dev/null +++ b/models/Teacher.php @@ -0,0 +1,58 @@ + 'ID', + 'teacher_name' => 'Teacher Name', + ]; + } + + /** + * relation Many-to-Many: many Student - many Teacher + * @return \yii\db\ActiveQuery + */ + public function getStudents() + { + return $this->hasMany(Student::className(), ['id' => 'student_id']) + ->viaTable('teacher_student', ['teacher_id' => 'id']); + } +} \ No newline at end of file diff --git a/models/TeacherSearch.php b/models/TeacherSearch.php new file mode 100644 index 0000000..d34d1a6 --- /dev/null +++ b/models/TeacherSearch.php @@ -0,0 +1,66 @@ + $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([ + 'id' => $this->id, + ]); + + $query->andFilterWhere(['like', 'teacher_name', $this->teacher_name]); + + return $dataProvider; + } +} \ No newline at end of file diff --git a/models/University.php b/models/University.php new file mode 100644 index 0000000..1c62fc4 --- /dev/null +++ b/models/University.php @@ -0,0 +1,57 @@ + 'ID', + 'university_name' => 'University Name', + ]; + } + + /** + * relation One-to-Many: One University - many Department + * @return \yii\db\ActiveQuery + */ + public function getDepartment() + { + return $this->hasMany(Department::className(), ['university_id' => 'id']); + } +} \ No newline at end of file diff --git a/models/UniversitySearch.php b/models/UniversitySearch.php new file mode 100644 index 0000000..3083396 --- /dev/null +++ b/models/UniversitySearch.php @@ -0,0 +1,66 @@ + $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([ + 'id' => $this->id, + ]); + + $query->andFilterWhere(['like', 'university_name', $this->university_name]); + + return $dataProvider; + } +} \ No newline at end of file diff --git a/views/department/_form.php b/views/department/_form.php new file mode 100644 index 0000000..57bf153 --- /dev/null +++ b/views/department/_form.php @@ -0,0 +1,26 @@ + + +
+ + + + field($model, 'department_name')->textInput(['maxlength' => true]) ?> + field($model, 'university_id')->dropDownList(University::find()->select(['university_name', 'id'])->indexBy('id')->column())->label('Select Univer name'); ?> +
+ isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/views/department/_search.php b/views/department/_search.php new file mode 100644 index 0000000..6a0c119 --- /dev/null +++ b/views/department/_search.php @@ -0,0 +1,29 @@ + + +
+ + ['index'], + 'method' => 'get', + ]); ?> + + field($model, 'id') ?> + + field($model, 'department_name') ?> + +
+ 'btn btn-primary']) ?> + 'btn btn-default']) ?> +
+ + + +
diff --git a/views/department/create.php b/views/department/create.php new file mode 100644 index 0000000..691d841 --- /dev/null +++ b/views/department/create.php @@ -0,0 +1,21 @@ +title = 'Create Department'; +$this->params['breadcrumbs'][] = ['label' => 'Department', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
\ No newline at end of file diff --git a/views/department/index.php b/views/department/index.php new file mode 100644 index 0000000..2a13520 --- /dev/null +++ b/views/department/index.php @@ -0,0 +1,33 @@ +title = 'Department'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

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

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

+ $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id', + 'department_name', + 'university_id', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
\ No newline at end of file diff --git a/views/department/update.php b/views/department/update.php new file mode 100644 index 0000000..a13a768 --- /dev/null +++ b/views/department/update.php @@ -0,0 +1,21 @@ +title = 'Update Department: ' . $model->department_name; +$this->params['breadcrumbs'][] = ['label' => 'Department', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->department_name, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/views/department/view.php b/views/department/view.php new file mode 100644 index 0000000..0f326a4 --- /dev/null +++ b/views/department/view.php @@ -0,0 +1,37 @@ +title = $model->department_name; +$this->params['breadcrumbs'][] = ['label' => 'Department', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

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

+ + $model, + 'attributes' => [ + 'id', + 'university_id', + 'department_name', + ], + ]) ?> + +
diff --git a/views/site/contact.php b/views/site/contact.php index f4c1e74..23dee71 100644 --- a/views/site/contact.php +++ b/views/site/contact.php @@ -65,4 +65,4 @@ - + \ No newline at end of file diff --git a/views/student/_form.php b/views/student/_form.php new file mode 100644 index 0000000..3b27c54 --- /dev/null +++ b/views/student/_form.php @@ -0,0 +1,29 @@ + + +
+ + + + field($model, 'student_name')->textInput(['maxlength' => true]) ?> + field($model, 'id')->dropDownList(Teacher::find()->select(['student_name', 'id'])->indexBy('id')->column())->label('Select Univer name'); ?> + +
+ isNewRecord ? 'Create' : 'Update', [ + 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/views/student/_search.php b/views/student/_search.php new file mode 100644 index 0000000..fd52ca8 --- /dev/null +++ b/views/student/_search.php @@ -0,0 +1,29 @@ + + +
+ + ['index'], + 'method' => 'get', + ]); ?> + + field($model, 'id') ?> + + field($model, 'student_name') ?> + +
+ 'btn btn-primary']) ?> + 'btn btn-default']) ?> +
+ + + +
diff --git a/views/student/create.php b/views/student/create.php new file mode 100644 index 0000000..fd82f70 --- /dev/null +++ b/views/student/create.php @@ -0,0 +1,21 @@ +title = 'Create Student'; +$this->params['breadcrumbs'][] = ['label' => 'Student', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
\ No newline at end of file diff --git a/views/student/index.php b/views/student/index.php new file mode 100644 index 0000000..38c634e --- /dev/null +++ b/views/student/index.php @@ -0,0 +1,32 @@ +title = 'Student'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

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

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

+ $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id', + 'student_name', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
\ No newline at end of file diff --git a/views/student/update.php b/views/student/update.php new file mode 100644 index 0000000..6fc6b33 --- /dev/null +++ b/views/student/update.php @@ -0,0 +1,21 @@ +title = 'Update Student: ' . $model->student_name; +$this->params['breadcrumbs'][] = ['label' => 'Student', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->student_name, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/views/student/view.php b/views/student/view.php new file mode 100644 index 0000000..d88b685 --- /dev/null +++ b/views/student/view.php @@ -0,0 +1,36 @@ +title = $model->student_name; +$this->params['breadcrumbs'][] = ['label' => 'Student', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

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

+ + $model, + 'attributes' => [ + 'id', + 'student_name', + ], + ]) ?> + +
diff --git a/views/teacher/_form.php b/views/teacher/_form.php new file mode 100644 index 0000000..8bb0200 --- /dev/null +++ b/views/teacher/_form.php @@ -0,0 +1,29 @@ + + +
+ + + + field($model, 'teacher_name')->textInput(['maxlength' => true]) ?> + field($model, 'id')->dropDownList(Student::find()->select(['student_name', 'id'])->indexBy('id')->column())->label('Select Univer name'); ?> + +
+ isNewRecord ? 'Create' : 'Update', [ + 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/views/teacher/_search.php b/views/teacher/_search.php new file mode 100644 index 0000000..1d50c4d --- /dev/null +++ b/views/teacher/_search.php @@ -0,0 +1,29 @@ + + +
+ + ['index'], + 'method' => 'get', + ]); ?> + + field($model, 'id') ?> + + field($model, 'teacher_name') ?> + +
+ 'btn btn-primary']) ?> + 'btn btn-default']) ?> +
+ + + +
diff --git a/views/teacher/create.php b/views/teacher/create.php new file mode 100644 index 0000000..4780961 --- /dev/null +++ b/views/teacher/create.php @@ -0,0 +1,21 @@ +title = 'Create Teacher'; +$this->params['breadcrumbs'][] = ['label' => 'Teacher', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
\ No newline at end of file diff --git a/views/teacher/index.php b/views/teacher/index.php new file mode 100644 index 0000000..117011a --- /dev/null +++ b/views/teacher/index.php @@ -0,0 +1,32 @@ +title = 'Teacher'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

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

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

+ $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id', + 'teacher_name', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
\ No newline at end of file diff --git a/views/teacher/update.php b/views/teacher/update.php new file mode 100644 index 0000000..046e5f3 --- /dev/null +++ b/views/teacher/update.php @@ -0,0 +1,21 @@ +title = 'Update Teacher: ' . $model->teacher_name; +$this->params['breadcrumbs'][] = ['label' => 'Teacher', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->teacher_name, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/views/teacher/view.php b/views/teacher/view.php new file mode 100644 index 0000000..87c48ef --- /dev/null +++ b/views/teacher/view.php @@ -0,0 +1,36 @@ +title = $model->teacher_name; +$this->params['breadcrumbs'][] = ['label' => 'Teacher', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

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

+ + $model, + 'attributes' => [ + 'id', + 'teacher_name', + ], + ]) ?> + +
diff --git a/views/university/_form.php b/views/university/_form.php new file mode 100644 index 0000000..4ac84d0 --- /dev/null +++ b/views/university/_form.php @@ -0,0 +1,23 @@ + + +
+ + + + field($model, 'university_name')->textInput(['maxlength' => true]) ?> + +
+ isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/views/university/_search.php b/views/university/_search.php new file mode 100644 index 0000000..b0c2e19 --- /dev/null +++ b/views/university/_search.php @@ -0,0 +1,29 @@ + + +
+ + ['index'], + 'method' => 'get', + ]); ?> + + field($model, 'id') ?> + + field($model, 'university_name') ?> + +
+ 'btn btn-primary']) ?> + 'btn btn-default']) ?> +
+ + + +
diff --git a/views/university/create.php b/views/university/create.php new file mode 100644 index 0000000..9bac410 --- /dev/null +++ b/views/university/create.php @@ -0,0 +1,21 @@ +title = 'Create University'; +$this->params['breadcrumbs'][] = ['label' => 'University', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
\ No newline at end of file diff --git a/views/university/index.php b/views/university/index.php new file mode 100644 index 0000000..76cd726 --- /dev/null +++ b/views/university/index.php @@ -0,0 +1,32 @@ +title = 'University'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

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

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

+ $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id', + 'university_name', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
\ No newline at end of file diff --git a/views/university/update.php b/views/university/update.php new file mode 100644 index 0000000..9f9fa46 --- /dev/null +++ b/views/university/update.php @@ -0,0 +1,21 @@ +title = 'Update University: ' . $model->university_name; +$this->params['breadcrumbs'][] = ['label' => 'University', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->university_name, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/views/university/view.php b/views/university/view.php new file mode 100644 index 0000000..b159813 --- /dev/null +++ b/views/university/view.php @@ -0,0 +1,36 @@ +title = $model->university_name; +$this->params['breadcrumbs'][] = ['label' => 'University', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

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

+ + $model, + 'attributes' => [ + 'id', + 'university_name', + ], + ]) ?> + +