say this is an example:
Use has time sheet configurations.
One of the user is project manager.
Project manager manages many departments.
User (1) - configuration (many)
User (1) - departments(many)
I used ' onDelete('cascade') in the configuration dedicated for the user. but I don't want to delete the department.
So is it okay to make a null?
Then how to make a null value ? in the migration file?
You should be able to use onDelete('set null') in the foreign key relation, but it is important to make sure that the field is also set to nullable.
$table->unsignedInteger('user_id')->nullable(); $table->foreign('user_id')->references('id')->on('users')->onDelete('set null');