php - How to keep logs of your users in Laravel 4? -
i have users
table in database lay out :
- id
- username
- firstname
- lastname
- photo
as of now, since admin
user have admin right
, , can create, update, , delete. want allow users have same right me later on. before release feature, want keep track on edit - things doesn't lost, , it's keep history of things.
what best practice feature ? know have programming logic in update function in controller function. know have create logs
table on database store
- user_id : make change
- created_at : when change made
- old_data: string
- new_data: string
for someone, had experiences feature, can please give me advice ? appreciate concern. thank you.
i think best approach problem each action user takes want log should fire event.
event::fire('some.event', array(auth::user()));
then can register listeners each event , log appropriately.
event::listen('some.event', function($user) { // create new item in logs table here. });
Comments
Post a Comment