From b2a2764dc383fed452a2b1d3b05079516528c9ed Mon Sep 17 00:00:00 2001 From: Abdalla Hisham Date: Mon, 27 May 2019 03:30:02 +0200 Subject: [PATCH] Add new tables for likes and comments --- app/{role.php => Comment.php} | 2 +- .../2019_05_27_012120_create_likes_table.php | 30 ++++++++++++++++++ ...019_05_27_012151_create_comments_table.php | 31 +++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) rename app/{role.php => Comment.php} (72%) create mode 100644 database/migrations/2019_05_27_012120_create_likes_table.php create mode 100644 database/migrations/2019_05_27_012151_create_comments_table.php diff --git a/app/role.php b/app/Comment.php similarity index 72% rename from app/role.php rename to app/Comment.php index 20efdbb..739e47e 100644 --- a/app/role.php +++ b/app/Comment.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class role extends Model +class Comment extends Model { // } diff --git a/database/migrations/2019_05_27_012120_create_likes_table.php b/database/migrations/2019_05_27_012120_create_likes_table.php new file mode 100644 index 0000000..291f80a --- /dev/null +++ b/database/migrations/2019_05_27_012120_create_likes_table.php @@ -0,0 +1,30 @@ +unsignedInteger('podcast_id')->index(); + $table->unsignedInteger('user_id')->index(); + $table->timestamps(); + + $table->primary(['podcast_id', 'user_id']); + }); + } + + /** + * Reverse the migrations. + */ + public function down() + { + Schema::dropIfExists('likes'); + } +} diff --git a/database/migrations/2019_05_27_012151_create_comments_table.php b/database/migrations/2019_05_27_012151_create_comments_table.php new file mode 100644 index 0000000..22c50b7 --- /dev/null +++ b/database/migrations/2019_05_27_012151_create_comments_table.php @@ -0,0 +1,31 @@ +bigIncrements('id'); + $table->unsignedInteger('podcast_id')->index(); + $table->unsignedInteger('user_id')->index(); + $table->text('body'); + $table->unsignedInteger('parent_id')->default(0); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down() + { + Schema::dropIfExists('comments'); + } +}