Skip to content

Commit

Permalink
Merge pull request #3 from abdallahisham/master
Browse files Browse the repository at this point in the history
Add new tables for likes and comments
  • Loading branch information
owiesnama authored May 30, 2019
2 parents 9316f2c + b2a2764 commit d1183ef
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 d1183ef

Please sign in to comment.