项目作者: orisintel

项目描述 :
Logs which process created or modified a record
高级语言: PHP
项目地址: git://github.com/orisintel/laravel-process-stamps.git
创建时间: 2018-09-04T14:14:07Z
项目社区:https://github.com/orisintel/laravel-process-stamps

开源协议:MIT License

下载


Laravel Process Stamps

Latest Version on Packagist
Build Status
Total Downloads

It is sometimes very useful to know which process created or modified a particular record in your database. This package provides a trait to add to your Laravel models which automatically logs that for you.

Installation

You can install the package via composer:

  1. composer require orisintel/laravel-process-stamps

Configuration

  1. php artisan vendor:publish --provider="\OrisIntel\ProcessStamps\ProcessStampsServiceProvider"

Running the above command will publish both the migration and the config file.

Usage

After adding the proper fields to your table, add the trait to your model.

  1. // User model
  2. class User extends Model
  3. {
  4. use ProcessStampable;

Next, create a migration for your table and include the following:

  1. $table->processIds();

To specify your own foreign key or index names, include the following options:

  1. $table->processIds([
  2. 'created_index_name' => 'custom_created_index_name',
  3. 'updated_index_name' => 'custom_updated_index_name',
  4. 'created_foreign_key_name' => 'custom_created_foreign_key_name',
  5. 'updated_foreign_key_name' => 'custom_updated_foreign_key_name',
  6. ]);

That will generate the nessesary field names to track processes.

Testing

  1. composer test

Using Docker

All assets are set up under the docker-compose.yml file. The first time you run the docker image you must build it with
the following command:

  1. docker-compose build

Then you can bring it up in the background using:

  1. docker-compose up -d

And the image is aliased so you can access its command line via:

  1. docker exec -it processes-stamp-app /bin/bash

From there you can run the tests within an isolated environment

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email opensource@orisintel.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.