Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

marsuch's avatar

Delete an image during editing

Hi, I have three tables. A table for images, a table for products and a pivot table to link the product to the images. I am currently doing product editing within which it is possible to remove some existing images, deleting an image as such is handled by JavaScript and API controller methods. And I am figuring out what is the best approach to serve this. The ideal solution seems to me to remove the image from the database and disk. And clean up the pivot table as part of the synchronization. Or would it be better to clean everything at once?

0 likes
1 reply
Snapey's avatar

One API end point, delete the file from memory and remove the image and the pivot entry all in the same controller.

Why would you defer cleaning up?

Please or to participate in this conversation.