Answer the question
In order to leave comments, you need to log in
How to implement cascading deletion not only from junction table in Laravel?
Hello, tell me please, I have a model Region and Image, a many-to-many relationship is defined between them. Accordingly, in the database of the table: regions, images, and the linking table image_region.
Link table migration here:
Schema::create('image_region', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('region_id');
$table->foreign('region_id')->references('id')->on('regions')->onDelete('cascade');
$table->unsignedBigInteger('image_id');
$table->foreign('image_id')->references('id')->on('images')->onDelete('cascade');
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question