“Migrasi Laravel ID Asing” Kode Jawaban

Migrasi Laravel ID Asing

$table->unsignedBigInteger('user_id');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
Imran Developer

asing di Laravel

// for laravel 7 or above. 
$table->foreignId('user_id')->constrained();
/*-----------OR---------------*/
$table->foreignId('user_id')->constrained('users');
Naveed Shahzad

Laravel 8 Migrasi Kunci Asing

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');
});
Combative Coyote

Migrasi Laravel Kunci Asing

$table->foreign('column_name')->references('id')->on('table_name')->onDelete('cascade');
Super Starling

Laravel membuat kolom kunci asing dalam migrasi

$table->foreignId('post_id')
                ->constrained()
                ->onUpdate('cascade')
                ->onDelete('cascade');
Akash

Jawaban yang mirip dengan “Migrasi Laravel ID Asing”

Pertanyaan yang mirip dengan “Migrasi Laravel ID Asing”

Lebih banyak jawaban terkait untuk “Migrasi Laravel ID Asing” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya