Skip to content

Instantly share code, notes, and snippets.

@EmmanuelObua
Last active May 13, 2021 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EmmanuelObua/e582f4d304e470bc1cdce9f38c76f373 to your computer and use it in GitHub Desktop.
Save EmmanuelObua/e582f4d304e470bc1cdce9f38c76f373 to your computer and use it in GitHub Desktop.
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