How to laravel 9 eloquent on delete set null schema code answer ,2024

in this article, we will learn about how to laravel 7 eloquent on delete set null schema

1). laravel migration on delete set null

Source: stackoverflow.com

$table->...->onDelete('set null');

2). laravel on delete set null

​Source: stackoverflow.com
$table->...->onDelete('set null');

#First make sure you set the foreign key field as nullable:
$table->integer('foreign_id')->unsigned()->nullable();

3). laravel 9 is eloquent on delete set null schema

$table->foreignId('user_id')
      ->constrained()
      ->onDelete('cascade');

Discover more from STRUGGLER KING.COM

Subscribe now to keep reading and get access to the full archive.

Continue Reading