“So erstellen Sie Fremdenschlüssel in Laravel” 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

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

Laravel 8 Fremdschlüsselwanderung

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

ausländische Key Laravel -Migration

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

So erstellen Sie Fremdenschlüssel in Laravel

$table->foreign('category_id')->references('id')->on('categories')->onUpdate('cascade')->onDelete('cascade');
Muhammad Ariq Rafi

Ähnliche Antworten wie “So erstellen Sie Fremdenschlüssel in Laravel”

Fragen ähnlich wie “So erstellen Sie Fremdenschlüssel in Laravel”

Weitere verwandte Antworten zu “So erstellen Sie Fremdenschlüssel in Laravel” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen