“Fremdschlüssel String Laravel” Code-Antworten

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

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

Laravel addiert fremde Schlüsselbeschränkungen

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

Laravel -Feldtypen vom Datenbankfeldtyp

// 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

Fremdschlüssel String Laravel

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

Ähnliche Antworten wie “Fremdschlüssel String Laravel”

Fragen ähnlich wie “Fremdschlüssel String Laravel”

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

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen