Model/Controller/Component: where to put my code

Hi all,

I am not sure where I should put my code in following case:

A user has multiple images on his "page" with the option to delete them. The photos are stored in a separate table with their own AR-model. This means I have a UserController, a PhotoController and the Photo model.

The delete method should delete the database entries as well as the actual files in the file system.

But where should I put my delete logic now?

Since I may need the option to delete photos from somewhere else too (maybe an admin page), I thought it is better to put them into either PhotoController or the Photo model.

What do you think?

Best regards

ycast

Put the logic in your Photo model, in onBeforeDelete or onAfterDelete

That way the same thing happens when you call delete on the model, regardless where you are calling it.

Great idea, thanks :)