It all depends really on what you need and expect to need in the future, in the current situation for example you won't know the date of a transaction made by a user since its stored on the event table of which a User will have none. Maybe its not needed but as you mentioned it might be a good starting point to reevaluate what your application needs to do and if the current structure is still ideal knowing what you know now.
Without knowing the rest of the application and the implications each approach might have further on, just some thoughts based on the questions;
-
You can make the event_id column nullable and add a user_id column to the transaction table. Then a user can have many transactions without having an event. Not a clean solution and you will loose the constraint you have at the database level now and will probably cause problems in places where you access the Event from a Transaction model for example.
-
You can drop the event_id column and go with the morphable route, but you also mentioned that you ran in to some issues with a specific scenario. Without knowing that exact scenario which you ran into I have no idea if it is insurmountable and therefore a viable option. To query the transaction table you can filter it down by the morpahble type e.g. select * from transaction where transactable_type = 'App\Seller' and transactable_id = 1; when you omit that you'll essentially be query the transactions for both the sellers and the users. This solution will also break the fk constraint on the database level.
This will let you do for example $event->transactions and $user->transactions
- You can drop the event_id column and create 2 pivot tables; transaction_user and transaction_event (with a composite unique constraint on the event_id and transaction_id columns) and query through these tables from the Event and User model. Almost the same as the morphable approach and if you are quite sure that you won't have other models making transactions in the future then I would personally prefer this above the morphable way as it is constrained in the database and not linked to direct models.
But then again it all depends on what the application is and does, might just be that none of these suggestions are any good.