database/migrations/2018_02_26_110729_create_projects_users_table.php
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateProjectsUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('projects_users', function (Blueprint $table) {
$table->integer('project_id')->unsigned();
$table->integer('user_id')->unsigned();
$table->string('role');
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('project_id')->references('id')->on('projects');
$table->primary(['project_id', 'user_id'], 'projects_users_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('projects_users');
}
}