KLM113's avatar
Level 2

Handling Relationships in a Reusable Module?

I developed a module for image CRUD operations in the admin panel. Thinking about reusing this module in future projects, I wonder if it would make sense to handle relationships at this stage or if I should simply leave it to each project's implementation.

The main issue is that I don’t yet know what relationships might exist. However, if I could provide a generic detach() alternative, I believe it could be useful.

Is it possible? And more importantly, is it advisable?

0 likes
1 reply
martinbean's avatar

@klm113 You could define a trait, that your application’s models should use, in order to add the functionality. Similarly to how Cashier offers a Billable trait that you then add to models you want to add subscriptions to.

Please or to participate in this conversation.