From 4cdbe1ab92d9a6f2c074bbae114b27770ee3eb01 Mon Sep 17 00:00:00 2001 From: "m.zargarov" Date: Tue, 7 May 2024 17:16:34 +0400 Subject: [PATCH] added Lesson model --- app/Models/Lesson.php | 17 +++++++++++ ...07_111420_create_student_subject_table.php | 3 +- ...2024_05_07_123620_create_lessons_table.php | 30 +++++++++++++++++++ ...455_add_foreign_key_to_student_subject.php | 28 +++++++++++++++++ 4 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 app/Models/Lesson.php create mode 100644 database/migrations/2024_05_07_123620_create_lessons_table.php create mode 100644 database/migrations/2024_05_07_125455_add_foreign_key_to_student_subject.php diff --git a/app/Models/Lesson.php b/app/Models/Lesson.php new file mode 100644 index 0000000..7506978 --- /dev/null +++ b/app/Models/Lesson.php @@ -0,0 +1,17 @@ +id(); $table->foreignId('student_id')->constrained('students')->onDelete('cascade'); $table->foreignId('subject_id')->constrained('subjects')->onDelete('cascade'); - $table->unsignedInteger('score'); + $table->unsignedInteger('mark'); $table->timestamps(); }); } diff --git a/database/migrations/2024_05_07_123620_create_lessons_table.php b/database/migrations/2024_05_07_123620_create_lessons_table.php new file mode 100644 index 0000000..7e3a76e --- /dev/null +++ b/database/migrations/2024_05_07_123620_create_lessons_table.php @@ -0,0 +1,30 @@ +id(); + $table->string('name'); + $table->string('type'); + $table->date('lesson_date')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('lessons'); + } +}; diff --git a/database/migrations/2024_05_07_125455_add_foreign_key_to_student_subject.php b/database/migrations/2024_05_07_125455_add_foreign_key_to_student_subject.php new file mode 100644 index 0000000..11a4b4a --- /dev/null +++ b/database/migrations/2024_05_07_125455_add_foreign_key_to_student_subject.php @@ -0,0 +1,28 @@ +foreignId('lesson_id')->constrained('lessons')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('student_subject', function (Blueprint $table) { + $table->dropColumn('lesson_id'); + }); + } +};