Horje
foreign key in laravel migration Code Example
foreign key in laravel migration
$table->unsignedBigInteger('user_id');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
laravel foreign key
Schema::table('posts', function (Blueprint $table) {
    $table->unsignedBigInteger('user_id');

    $table->foreign('user_id')->references('id')->on('users');
});
OR
Schema::table('posts', function (Blueprint $table) {
    $table->foreignId('user_id')->constrained();
});
foreign key laravel migration
$table->foreign('column_name')->references('id')->on('table_name')->onDelete('cascade');
laravel 8 foreign key migration
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

Schema::table('posts', function (Blueprint $table) {
    $table->unsignedBigInteger('user_id');

    $table->foreign('user_id')->references('id')->on('users');
});
Source: laravel.com




Php

Related
php curl post json Code Example php curl post json Code Example
laravel permission spatie cache clear Code Example laravel permission spatie cache clear Code Example
make a forign key in migrations using laravel 8 Code Example make a forign key in migrations using laravel 8 Code Example
ubuntu 20.04 how to install npm Code Example ubuntu 20.04 how to install npm Code Example
foreign id laravel migration Code Example foreign id laravel migration Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9