I am hoping that someone would be able to give me some advice or direction.
I have multiple tables, these tables have created_by and updated_by columns. I use these fields to determine who created the record and also who modified it last. ( Just a quick and simple method to audit changes).
I have 2 questions if I may: 1. Is this a good way to do auditing (keeping track of the creator / modifier)? 2. What is the best way to update these fields. Do I make use of Eloquent events or is there a better alternative? Any pointers would be awesome.
Thank you!
I would strongly suggest checking out something like laravel-auditing. It gives a rich auditing log for your eloquent models and fits straight into Laravel.
Say you have your Eloquent model then all you need to do is carry out the appropriate setup instructions and add the
OwenIt\Auditing\AuditingTrait
to your models that you want to keep an audit log for.Saves significantly re-inventing the wheel.