How to keep logs of your users in Laravel 4?

iori

I have users table in my database lay out like this :

  • id
  • username
  • firstname
  • lastname
  • email
  • photo

As of now, since I am an Admin user so I have Admin right, and I can Create, Update, and Delete. I want to allow all my users to have the same right as me later on. Before I release this feature, I want to keep track on who edit what - so things doesn't get lost, and it's good to keep the history of things.

What is best practice for this feature ? I know that I have do some programming logic in my update function in my Controller function. I know that I have to create a logs table on my database to store

  • user_id : who make a change
  • created_at : when the change was made
  • old_data: string
  • new_data: string

For someone, that had any experiences with this feature, can you PLEASE give me some advice ? I really appreciate your concern. Thank You.

user1669496

I think best approach to this problem is each action that a user takes that you want to log should also fire an event.

Event::fire('some.event', array(Auth::user()));

Then you can register listeners for each event and log appropriately.

Event::listen('some.event', function($user)
{
    // create new item in logs table here.
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to orderedBy your table when users click on table header in Laravel 4?

How to keep logs for ECS container?

UnitOfWork: How to rollback and keep the logs

Laravel: Users birthday resets when user logs on

How to keep track of processed users?

How to keep precision entered by users?

How can we keep the installation logs to a limited amount of logs?

How to disable laravel logs temporarily?

how to parse laravel logs in fluentd

Laravel: Is it possible to save all actions of users in logs or db?

How to keep adding to your values (int) in java?

How to keep your data when model changes?

How to keep fractions in your equation output

How to keep your old migration as reference?

Use a regex to keep the access logs with HTTP response 4** and 5**

Does ServiceStack 4 keep logs of the received HTTP request?

set keep_logical_logs in embedded Neo4j

How to keep web content below the users view?

When the user logs in how can I get that particular users details?

How do I keep track of users info without having them log in (Using asp.net mvc4 with Visual Studio)

laravel eloquent - how to select users

How Can I Keep 14 Days of Logs using Logrotate?

How to keep on appending logs while writing into File in SDCard?

How to stop journalctl showing audit logs and only keep them in file?

How to stop journalctl showing audit logs and only keep it in a file?

Laravel 4 dynamic menu: "Route::is('users/*')" not working

How to debug Laravel error 500 with no logs, no information

How to Save Laravel rest Api logs into db

How do I view server logs in Laravel?