Skip to content

MediciVN/eloquent-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EloquentLogger

Automatically update the logger when updating a model.

How to use:

  • First, a root node must be initialized in your model's table
  • Add use ActivityLogTrait; to your eloquent model, example:
use Medicivn\EloquentLogger\ActivityLogTrait;

class UserTest extends Model
{
    use HasFactory, ActivityLogTrait;
    
    /**
    * The column need note write the change
    *
    * Default: []
    */
    const LOGGABLE = [
        'name',
    ];
    
    /**
    * The model name to record changes
    *
    * Default: null
    */
    const MODEL_NAME_LOG = ActivityUserTestLog::class;
    

Function

  • writeLog: write logger when changing data

Notes

  • If you are using ActivityLogTrait for MySQL then create a table with the following columns
    • model_id
    • url
    • time
    • creator
    • creator_id
    • action
    • key
    • old_value
    • new_value

About

Save changes of Eloquent Model to MongoDB

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages