“string kunci asing laravel” Kode Jawaban

Laravel Kunci Asing

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();
});
Courageous Cod

Laravel Kendala Kunci Asing

public function up()
{
    Schema::create('replies', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->text('body');
        $table->unsignedBigInteger('question_id');
        $table->integer('user_id')->unsigned();
        $table->foreign('question_id')->references('id')->on('questions')->onDelete('cascade');
        $table->timestamps();
    });
}
Brave Butterfly

Laravel Menambahkan kendala kunci asing

$table->foreignId('user_id')
      ->constrained("users") <- // You don't need to specify table if it matched laravel naming conventions.
      ->onUpdate('cascade')
      ->onDelete('cascade');
kelraf

Jenis bidang Laravel dari jenis bidang database

// in laravel if error of missing pdomysql driver issue the command
// composer require doctrine/dbal
DB::connection()->getDoctrineColumn($table_name, $field_name)->getType()->getName()
Gegasoft

string kunci asing laravel

Schema::table('portfolios', function (Blueprint $table) {
            $table->string('filter_alias');
            $table->foreign('filter_alias')->cascadeOnDelete()->references('alias')->on('filters');
        });
Open Okapi

Jawaban yang mirip dengan “string kunci asing laravel”

Pertanyaan yang mirip dengan “string kunci asing laravel”

Lebih banyak jawaban terkait untuk “string kunci asing laravel” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya