Skip to content

Commit

Permalink
Add new tables for likes and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
abdallahisham committed May 27, 2019
1 parent adcc512 commit b2a2764
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/role.php → app/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Database\Eloquent\Model;

class role extends Model
class Comment extends Model
{
//
}
30 changes: 30 additions & 0 deletions database/migrations/2019_05_27_012120_create_likes_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateLikesTable extends Migration
{
/**
* Run the migrations.
*/
public function up()
{
Schema::create('likes', function (Blueprint $table) {
$table->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');
}
}
31 changes: 31 additions & 0 deletions database/migrations/2019_05_27_012151_create_comments_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCommentsTable extends Migration
{
/**
* Run the migrations.
*/
public function up()
{
Schema::create('comments', function (Blueprint $table) {
$table->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');
}
}

0 comments on commit b2a2764

Please sign in to comment.