jeudi 28 février 2019

Seperation of concerns - Controlling 2 dependant entities by using a service?

I have 2 services, a profileService which knows how to manipulate Profile models (laravel eloquent). And a listService which knows how to manipulate List models. A profile has a one to many relation with the List model. The relations are defined in those eloquent models.

Now, the question i have is about separation of concerns. I intend to let the profile service only do stuff with profiles. And the listService only with lists.

What kind of design pattern / construction would i need to do the following while respecting my intentions:

I want a destroyProfile method on the profile method which can delete the profile, and cause its related lists also to be deleted.

What i am thinking of is the following. I think i need a third service like class that the profileService can use to delete both models. But i am not sure what would be a nice way to do it.

Would you like to share your thoughts?

Thanks in advance!

J.

Aucun commentaire:

Enregistrer un commentaire