“Laravel Fremd Schlüsselbeschränkungen” 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

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

ausländische Key Laravel -Migration

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

Laravel Fremd Schlüsselbeschränkungen

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

Ähnliche Antworten wie “Laravel Fremd Schlüsselbeschränkungen”

Fragen ähnlich wie “Laravel Fremd Schlüsselbeschränkungen”

Weitere verwandte Antworten zu “Laravel Fremd Schlüsselbeschränkungen” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen