1Schema::table('posts', function (Blueprint $table) {
2 $table->unsignedBigInteger('user_id');
3
4 $table->foreign('user_id')->references('id')->on('users');
5});
6OR
7Schema::table('posts', function (Blueprint $table) {
8 $table->foreignId('user_id')->constrained();
9});
1Schema::create('posts', function ($table) {
2 $table->increments('id');
3 $table->integer('user_id');
4 // ...
5 $table->longText('description');
6 // ...
7}
8