Answers for "on delete cascade laravel"

PHP
2

how work cascade laravel

Schema::create('posts', function (Blueprint $table) {
    $table->increments('id');
    $table->integer('author')->unsigned();
    $table->timestamps();
    $table->foreign('author')->references('id')->on('users')->onUpdate('cascade');
});
Posted by: Guest on July-19-2021
1

cascade laravel

Schema::create('posts', function (Blueprint $table) {
    $table->id();
    $table->foreignId('author')->constrained('users')->onDelete('cascade')->onUpdate('cascade');
    $table->timestamps();
});
Posted by: Guest on July-25-2021
0

how set cascade on delete and update in same time in laravel

$table->foreign('user_id')->references('id')->on('users')
->onDelete('SET NULL')
->onUpdate('SET NULL'); // also available CASCADE, RESTRICT, DO NOTHING, NO ACTION
Posted by: Guest on July-22-2021

Code answers related to "on delete cascade laravel"

Browse Popular Code Answers by Language