Answer the question
In order to leave comments, you need to log in
How to implement the removal of images when removing a product from the store?
There is an online store. The database contains tables:
Categories; subcategories; products; product_images;
Product_images stores image paths.
What is the best way to implement the removal of the actual images when deleting a product.
Now I've set it up via Foreign keys so that when a category is deleted, its subcategories will be automatically deleted.
Behind the subcategory, its products are deleted, and after the products, information about their images from the database is also deleted.
Example:
$table->foreign('product_id')->references('id')->on('products')->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