//acording to laravel 7>=
Schema::table('posts', function (Blueprint $table) {
$table->foreignId('user_id')->constrained();
});
//for deffirent table
$table->foreignId('user_id')->constrained('users');
//for taking action
$table->foreignId('user_id')
->constrained()
->onUpdate('cascade')
->onDelete('cascade');