Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Posts migration
<?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