“Laravel Fremdschlüssel” Code-Antworten

Fremdschlüssel in der Laravel -Migration

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

Laravel Fremdschlüssel

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

Fremdschlüssel in Laravel

// one_line code for foreign in laravel
$table->foreignId('user_id')->constrained()->onDelete('cascade');
Enthusiastic Emu

Fügen Sie Fremdschlüsselsäule Laravel 5.8 hinzu

update your `integer('user_id')` to `bigInteger('user_id')`
public function up() { 
        Schema::create('evaluation', function (Blueprint $table) { 
            $table->increments('id'); 
            $table->bigInteger('user_id')->unsigned()->index(); 
            $table->timestamps();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
        });
    }
Splendid Stoat

Erstellen Sie fremde Key Laravel -Migration

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

    $table->foreign('user_id')->references('id')->on('users');
});
Super Starling

Laravel Fremdschlüssel

//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');
hansal

Ähnliche Antworten wie “Laravel Fremdschlüssel”

Fragen ähnlich wie “Laravel Fremdschlüssel”

Weitere verwandte Antworten zu “Laravel Fremdschlüssel” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen