Answer the question
In order to leave comments, you need to log in
How to assign default value for onUpdate/onDelete in Laravel (MySQL)?
Is there a way to set somewhere, for example in configuration files, the default value for onUpdate and onDelete?
MySQL itself defaults to no action (equivalent to restrict). I need to put cascade for all onUpdate.
Or maybe there is something like this in MySQL itself in the database settings..
Answer the question
In order to leave comments, you need to log in
It's not very clear what exactly you want to get. Something like this:
Schema::table('devices', function (Blueprint $table) {
$table->foreignId('user_id')->constrained()->onDelete('cascade');
$table->foreignId('car_id')->nullable()->constrained()->onDelete('set null');
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question