laravel on delete set null code example
Example 1: laravel migration on delete set null
$table->...->onDelete('set null');
Example 2: laravel on delete set null
$table->...->onDelete('set null');
#First make sure you set the foreign key field as nullable:
$table->integer('foreign_id')->unsigned()->nullable();
Example 3: laravel 7 eloquent on delete set null schema
$table->foreignId('user_id')
->constrained()
->onDelete('cascade');