diff --git a/app/Http/Controllers/WatchlistController.php b/app/Http/Controllers/WatchlistController.php new file mode 100644 index 0000000..3bfef0a --- /dev/null +++ b/app/Http/Controllers/WatchlistController.php @@ -0,0 +1,65 @@ +unsignedBigInteger('last_viewed_material_id')->index()->nullable(); $table->timestamp('last_viewed_at')->nullable(); $table->timestamps(); - $table->softDeletes(); + $table->softDeletes(); $table->foreign('student_id')->references('id')->on('students')->onDelete('cascade'); $table->foreign('course_id')->references('id')->on('courses')->onDelete('cascade'); diff --git a/database/migrations/2023_12_20_031354_create_watchlists_table.php b/database/migrations/2023_12_20_031354_create_watchlists_table.php new file mode 100644 index 0000000..0e249c2 --- /dev/null +++ b/database/migrations/2023_12_20_031354_create_watchlists_table.php @@ -0,0 +1,37 @@ +id(); + $table->unsignedBigInteger('student_id')->index(); + $table->unsignedBigInteger('course_id')->index(); + $table->unsignedBigInteger('lesson_id')->index(); + $table->unsignedBigInteger('material_id')->index(); + $table->timestamps(); + $table->softDeletes(); + + $table->foreign('student_id')->references('id')->on('students')->onDelete('cascade'); + $table->foreign('course_id')->references('id')->on('courses')->onDelete('cascade'); + $table->foreign('lesson_id')->references('id')->on('lessons')->onDelete('cascade'); + $table->foreign('material_id')->references('id')->on('materials')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('watchlists'); + } +};