daijiro of Techpit
3/7/2020 - 1:29 AM

年月日時分秒_create_articles_table.php

<?php
//-- 略
class CreateArticlesTable extends Migration
{
    //-- 略
    public function up()
    {
        Schema::create('articles', function (Blueprint $table) {
            $table->bigIncrements('id');
            //==========ここから追加==========
            $table->string('title');
            $table->text('body');
            $table->bigInteger('user_id');
            $table->foreign('user_id')->references('id')->on('users');
            //==========ここまで追加==========
            $table->timestamps();
        });
    }
}
//-- 略