PHPackages                             richan-fongdasen/eloquent-blameable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. richan-fongdasen/eloquent-blameable

ActiveLibrary[Database &amp; ORM](/categories/database)

richan-fongdasen/eloquent-blameable
===================================

Blameable behavior implementation for your Eloquent Model in Laravel

1.11.0(1y ago)34213.1k—5.5%5[1 PRs](https://github.com/richan-fongdasen/eloquent-blameable/pulls)3MITPHPPHP ^8.0CI failing

Since Jul 13Pushed 1y ago3 watchersCompare

[ Source](https://github.com/richan-fongdasen/eloquent-blameable)[ Packagist](https://packagist.org/packages/richan-fongdasen/eloquent-blameable)[ Docs](https://github.com/richan-fongdasen/eloquent-blameable)[ RSS](/packages/richan-fongdasen-eloquent-blameable/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (21)Used By (3)

[![CI](https://github.com/richan-fongdasen/eloquent-blameable/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/richan-fongdasen/eloquent-blameable/actions/workflows/main.yml)[![codecov](https://camo.githubusercontent.com/70723cda7ae78fc900f2badbce820ebd31a1106b5536d0a205caf4706ea33382/68747470733a2f2f636f6465636f762e696f2f67682f72696368616e2d666f6e67646173656e2f656c6f7175656e742d626c616d6561626c652f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/richan-fongdasen/eloquent-blameable)[![Total Downloads](https://camo.githubusercontent.com/139465c02db8884cc42f1fc6d36f67b198e74c1ebca05cb0482288e4f6b210f0/68747470733a2f2f706f7365722e707567782e6f72672f72696368616e2d666f6e67646173656e2f656c6f7175656e742d626c616d6561626c652f642f746f74616c2e737667)](https://packagist.org/packages/richan-fongdasen/eloquent-blameable)[![Latest Stable Version](https://camo.githubusercontent.com/b32ee93eea7ee54a6e515f0b7f08a9b4eb65378310ab77829fa1de489b4fb731/68747470733a2f2f706f7365722e707567782e6f72672f72696368616e2d666f6e67646173656e2f656c6f7175656e742d626c616d6561626c652f762f737461626c652e737667)](https://packagist.org/packages/richan-fongdasen/eloquent-blameable)[![License: MIT](https://camo.githubusercontent.com/f45d904953153ca304a2328243d2733e095eee13a631a1f390709885d41dd692/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2f6672616d65776f726b2f6c6963656e73652e737667)](https://opensource.org/licenses/MIT)

Eloquent Blameable
==================

[](#eloquent-blameable)

> Blameable behavior implementation for your Eloquent Model in Laravel

Synopsis
--------

[](#synopsis)

This package would help you to track the creator and updater of each database record. It would be done by filling the specified attributes with the current user ID automatically. By default, those attributes would be filled when you are saving the Eloquent Model object.

Table of contents
-----------------

[](#table-of-contents)

- [Setup](#setup)
- [Configuration](#configuration)
- [Usage](#usage)
- [License](#license)

Setup
-----

[](#setup)

Install the package via Composer :

```
$ composer require richan-fongdasen/eloquent-blameable
```

### Laravel version compatibility

[](#laravel-version-compatibility)

Laravel versionBlameable version5.1.x1.0.x5.2.x - 5.4.x1.1.x - 1.2.x5.5.x - 5.8.x1.3.x6.x1.4.x7.x1.5.x8.x1.6.x9.x1.8.x10.x1.9.x10.x1.10.x> If you are using Laravel version 5.5+ then you can skip registering the service provider in your Laravel application.

### Service Provider

[](#service-provider)

Add the package service provider in your `config/app.php`

```
'providers' => [
    // ...
    RichanFongdasen\EloquentBlameable\ServiceProvider::class,
];
```

Configuration
-------------

[](#configuration)

Publish configuration file using `php artisan` command

```
$ php artisan vendor:publish --provider="RichanFongdasen\EloquentBlameable\ServiceProvider"
```

The command above would copy a new configuration file to `/config/blameable.php`

```
return [

    /*
    |--------------------------------------------------------------------------
    | Authentication Guard
    |--------------------------------------------------------------------------
    |
    | Please specify your default authentication guard to be used by blameable
    | service. You can leave this to null if you're using the default Laravel
    | authentication guard.
    |
    | You can also override this value in model classes to use a different
    | authentication guard for your specific models.
    | IE: Some of your models can only be created / updated by specific users
    | who logged in from a specific authentication guard.
    |
    */

    'guard' => null,

    /*
    |--------------------------------------------------------------------------
    | User Model Definition
    |--------------------------------------------------------------------------
    |
    | Please specify a user model that should be used to setup `creator`
    | and `updater` relationship.
    |
    */

    'user' => \App\User::class,

    /*
    |--------------------------------------------------------------------------
    | The `createdBy` attribute
    |--------------------------------------------------------------------------
    |
    | Please define an attribute to use when recording the creator
    | identifier.
    |
    */

    'createdBy' => 'created_by',

    /*
    |--------------------------------------------------------------------------
    | The `updatedBy` attribute
    |--------------------------------------------------------------------------
    |
    | Please define an attribute to use when recording the updater
    | identifier.
    |
    */

    'updatedBy' => 'updated_by',

    /*
    |--------------------------------------------------------------------------
    | The `deletedBy` attribute
    |--------------------------------------------------------------------------
    |
    | Please define an attribute to use when recording the user
    | identifier who deleted the record. This feature would only work
    | if you are using SoftDeletes in your model.
    |
    */

    'deletedBy' => 'deleted_by',
];
```

Usage
-----

[](#usage)

### Add some blameable attributes to your migrations

[](#add-some-blameable-attributes-to-your-migrations)

```
Schema::create('some_tables', function (Blueprint $table) {
    // ...

    $table->integer('created_by')->nullable();
    $table->integer('updated_by')->nullable();
    $table->integer('deleted_by')->nullable();

    // ...

    /**
     * You can also create foreign key constrains
     * for the blameable attributes.
     */
    $table->foreign('created_by')
        ->references('id')->on('users')
        ->onDelete('cascade');

    $table->foreign('updated_by')
        ->references('id')->on('users')
        ->onDelete('cascade');
});
```

### Attach Blameable behavior into your Model

[](#attach-blameable-behavior-into-your-model)

```
use Illuminate\Database\Eloquent\Model;
use RichanFongdasen\EloquentBlameable\BlameableTrait;

class Post extends Model
{
    use BlameableTrait;

    // ...
}
```

### Override default configuration using static property

[](#override-default-configuration-using-static-property)

```
    /**
     * You can override the default configuration
     * by defining this static property in your Model
     */
    protected static $blameable = [
        'guard' => 'customGuard',
        'user' => \App\User::class,
        'createdBy' => 'user_id',
        'updatedBy' => null
    ];
```

### Override default configuration using public method

[](#override-default-configuration-using-public-method)

```
    /**
     * You can override the default configuration
     * by defining this method in your Model
     */
    public function blameable()
    {
        return [
            'guard' => 'customGuard',
            'user' => \App\User::class,
            'createdBy' => 'user_id',
            'updatedBy' => null
        ];
    }
```

### Using Blameable Query Scopes

[](#using-blameable-query-scopes)

```
// Get all posts which have created by the given user id
Post::createdBy($userId)->get();

// Get all posts which have updated by the given user object
$user = User::findOrFail(1);
Post::updatedBy($user)->get();
```

### Accessing Creator / Updater Object

[](#accessing-creator--updater-object)

```
// Get the creator user object
Post::findOrFail($postId)->creator;

// Get the updater user object
Post::findOrFail($postId)->updater;
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance44

Moderate activity, may be stable

Popularity45

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 88.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~146 days

Recently: every ~375 days

Total

20

Last Release

444d ago

Major Versions

0.2.0 → 1.0.02018-03-11

PHP version history (8 changes)0.1.0PHP ^5.5.9 || ^7.0

1.0.0PHP ^5.5.9 || ^7.0 || ^7.1.3

1.3.0PHP ^7.1.3

1.4.0PHP ^7.2

1.6.0PHP ^7.3

1.7.0PHP ^7.3|^8.0

1.8.0PHP ^7.4|^8.0

1.10.0PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5222595?v=4)[Richan Fongdasen](/maintainers/richan-fongdasen)[@richan-fongdasen](https://github.com/richan-fongdasen)

---

Top Contributors

[![richan-fongdasen](https://avatars.githubusercontent.com/u/5222595?v=4)](https://github.com/richan-fongdasen "richan-fongdasen (107 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (3 commits)")[![danielbehrendt](https://avatars.githubusercontent.com/u/283437?v=4)](https://github.com/danielbehrendt "danielbehrendt (2 commits)")[![andyundso](https://avatars.githubusercontent.com/u/7010698?v=4)](https://github.com/andyundso "andyundso (2 commits)")[![bakerkretzmar](https://avatars.githubusercontent.com/u/18192441?v=4)](https://github.com/bakerkretzmar "bakerkretzmar (2 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (2 commits)")[![diegotibi](https://avatars.githubusercontent.com/u/25210612?v=4)](https://github.com/diegotibi "diegotibi (1 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (1 commits)")[![juventus18](https://avatars.githubusercontent.com/u/1124513?v=4)](https://github.com/juventus18 "juventus18 (1 commits)")

---

Tags

blameableeloquenteloquent-modelslaravellaravel-5-packagelaraveleloquentlaravel-packageBlameable

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/richan-fongdasen-eloquent-blameable/health.svg)

```
[![Health](https://phpackages.com/badges/richan-fongdasen-eloquent-blameable/health.svg)](https://phpackages.com/packages/richan-fongdasen-eloquent-blameable)
```

###  Alternatives

[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k302.7k1](/packages/cybercog-laravel-love)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)[io238/laravel-iso-countries

Ready-to-use Laravel models and relations for country (ISO 3166), language (ISO 639-1), and currency (ISO 4217) information with multi-language support.

5462.3k](/packages/io238-laravel-iso-countries)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
