2017 © Pedro Peláez
 

library culpa

Adds Blameable support to Eloquent models in Laravel 5

image

nstapelbroek/culpa

Adds Blameable support to Eloquent models in Laravel 5

  • Friday, January 12, 2018
  • by nstapelbroek
  • Repository
  • 2 Watchers
  • 11 Stars
  • 13,189 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 6 Versions
  • 17 % Grown

The README.md

Culpa for Laravel 5 & 6 Build Status Latest Stable Version License

Blameable extension for Laravel 5 & 6 Eloquent ORM models. This extension automatically adds references to the authenticated user when creating, updating or soft-deleting a model., (*1)

Disclaimer: I've created this repository because I didn't want to include a dev-master version of the original fork in my composer.json. Once the original pull request gets merged, this package will probably become deprecated and you'll be best of switching back within a year. Due to changes in the namespace and directory structure this package is not backwards compatible with the original Culpa for laravel < 4., (*2)

Installation

To install the package in your project:, (*3)

  1. Run composer require nstapelbroek/culpa,
  2. Add to the providers list in config/app.php: "Culpa\CulpaServiceProvider",
  3. Publish the configuration to your application: php artisan vendor:publish

Usage

You can add auditable fields on a per-model basis by adding a protected property and a model observer. The property $blameable contains events you wish to record - at present this is restricted to created, updated and deleted - which function the same as Laravel's timestamps., (*4)

use Culpa\Traits\Blameable;
use Culpa\Traits\CreatedBy;
use Culpa\Traits\DeletedBy;
use Culpa\Traits\UpdatedBy;
use Illuminate\Database\Eloquent\Model;

class Comment extends Model
{
    use Blameable, CreatedBy, UpdatedBy, DeletedBy;

    protected $blameable = array('created', 'updated', 'deleted');

    // Other model logic here
}
  • On create, the authenticated user will be set in created_by,
  • On create and update, the authenticated user will be set in updated_by,
  • If the model was soft-deletable, the authenticated user will be set in deleted_by on deletion.

To activate the automatic updating of these fields, you need to add the blamable trait to the model. That's it! Need more tweak options for Culpa? take a look at the [Tweaks and Configuration docs](docs/1. Tweaks and Configuration.md)., (*5)

License

Culpa is released under the MIT License., (*6)

The Versions

12/01 2018

dev-master

9999999-dev https://github.com/nstapelbroek/culpa-laravel-5

Adds Blameable support to Eloquent models in Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nico Stapelbroek

laravel blameable created-by blamable updated-by deleted-by

12/01 2018

3.0.0

3.0.0.0 https://github.com/nstapelbroek/culpa-laravel-5

Adds Blameable support to Eloquent models in Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nico Stapelbroek

laravel blameable created-by blamable updated-by deleted-by

12/01 2018

dev-feature/update-dependencies

dev-feature/update-dependencies https://github.com/nstapelbroek/culpa-laravel-5

Adds Blameable support to Eloquent models in Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nico Stapelbroek

laravel blameable created-by blamable updated-by deleted-by

08/01 2016

2.0

2.0.0.0 https://github.com/nstapelbroek/culpa-laravel-5

Adds Blameable support to Eloquent models in Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nico Stapelbroek

laravel blameable created-by blamable updated-by deleted-by

08/01 2016

dev-develop

dev-develop https://github.com/nstapelbroek/culpa-laravel-5

Adds Blameable support to Eloquent models in Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nico Stapelbroek

laravel blameable created-by blamable updated-by deleted-by

08/01 2016

1.0

1.0.0.0 https://github.com/nstapelbroek/culpa-laravel-5

Adds Blameable support to Eloquent models in Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nico Stapelbroek

laravel blameable created-by blamable updated-by deleted-by