php - How to keep logs of your users in Laravel 4? -


i have users table in database lay out :

  • id
  • username
  • firstname
  • lastname
  • email
  • 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

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -