You might want to look into 'polymorphic' relations. That's what I've just been using for a log table. There's a video on here if you search or the laravel docs have a section on it too.
How to create a "all purpose" activity/log table
Hi!
I am about to start creating an activity/log feature on my site, and I am not sure how to solve this using a single table.
I want to log actions like: user sent a sms to, case updated, customer updated, status changed etc.
I was thinking about doing it this way: *id primary
*customer_id int nullable
*case_id int nullable
*type int
*title var
*text text
*user_id int null
*timestamps datetime
Will it be problematic that multiple fields will potentially have NULL value?
I have also considered this: *id primary
*type int
*external_id int (for case_id, customer_id etc.)
*title var
*text text
*user_id int
*timestamps datetime
Is there a better way of doing this?
Please or to participate in this conversation.