Package Data | |
---|---|
Maintainer Username: | nstapelbroek |
Maintainer Contact: | ross@rossmasters.com (Ross Masters) |
Package Create Date: | 2016-01-08 |
Package Last Update: | 2021-04-30 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-05-09 03:02:46 |
Package Statistics | |
---|---|
Total Downloads: | 67,966 |
Monthly Downloads: | 1,147 |
Daily Downloads: | 5 |
Total Stars: | 17 |
Total Watchers: | 4 |
Total Forks: | 5 |
Total Open Issues: | 2 |
Blameable extension for Laravel 5 Eloquent ORM models. This extension automatically adds references to the authenticated user when creating, updating or soft-deleting a model.
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.
This package works with Laravel 5.1 (running PHP 5.6+).
To install the package in your project:
composer require nstapelbroek/culpa
,providers
list in config/app.php:
"Culpa\CulpaServiceProvider"
,php artisan vendor:publish
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.
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;
protected $blameable = array('created', 'updated', 'deleted');
// Other model logic here
}
created_by
,updated_by
,deleted_by
.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).
Culpa is released under the MIT License.