Last active
May 13, 2021 08:38
-
-
Save EmmanuelObua/e582f4d304e470bc1cdce9f38c76f373 to your computer and use it in GitHub Desktop.
Posts migration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Schema::create('posts', function (Blueprint $table) { | |
$table->id(); | |
$table->unsignedBigInteger('user_id'); | |
$table->foreign('user_id')->references('id')->on('users'); | |
//It can be done like this as well in a more simplified way | |
//$table->foreignId('user_id')->constrained(); | |
$table->timestamps(); | |
}); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment