PHPackages                             m1guelpf/eloquent-immutable - 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. m1guelpf/eloquent-immutable

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

m1guelpf/eloquent-immutable
===========================

Enforce table immutability using Laravel Eloquent

62[1 issues](https://github.com/m1guelpf/eloquent-immutable/issues)[1 PRs](https://github.com/m1guelpf/eloquent-immutable/pulls)PHP

Since Oct 31Pushed 6y agoCompare

[ Source](https://github.com/m1guelpf/eloquent-immutable)[ Packagist](https://packagist.org/packages/m1guelpf/eloquent-immutable)[ RSS](/packages/m1guelpf-eloquent-immutable/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (2)Used By (0)

Enforce table immutability using Laravel Eloquent
=================================================

[](#enforce-table-immutability-using-laravel-eloquent)

[![Latest Version on Packagist](https://camo.githubusercontent.com/902ccba442d555064795823a1c089b2db121f82edfe01231a1507ad84d8250a5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d316775656c70662f656c6f7175656e742d696d6d757461626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/m1guelpf/eloquent-immutable)[![Total Downloads](https://camo.githubusercontent.com/2c0aa8e2283c5a6a04634e020dcf2365702f9e5179780594392e972189c779d4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d316775656c70662f656c6f7175656e742d696d6d757461626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/m1guelpf/eloquent-immutable)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require m1guelpf/eloquent-immutable
```

Usage
-----

[](#usage)

To make a model immutable, you'll first need to add the immutable trait to it:

```
use Illuminate\Database\Eloquent\Model;
use M1guelpf\EloquentImmutable\Immutable;

class YourModel extends Model {
    use Immutable;

    //
}
```

You can optionally enable an extra layer of security by storing a hash of the model's properties in your database. To do this, add a field to your migration, then toggle the fature in the model:

```
// database/migrations/2014_10_12_000000_create_your_table.php
Schema::create('your_table', function (Blueprint $table) {
    $table->string('hash');

    //
});

// app/YourModel.php
class YourModel extends Model {
    $immutableCheck = true;

    //
}
```

We'll automatically check the hash matches when the model is retrieved.

Limitations
-----------

[](#limitations)

Due to Laravel limitations, we cannot hook into mass updates or mass deletes.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

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

Credits
-------

[](#credits)

- [Miguel Piedrafita](https://github.com/m1guelpf)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/23558090?v=4)[Miguel Piedrafita](/maintainers/m1guelpf)[@m1guelpf](https://github.com/m1guelpf)

---

Top Contributors

[![m1guelpf](https://avatars.githubusercontent.com/u/23558090?v=4)](https://github.com/m1guelpf "m1guelpf (1 commits)")

### Embed Badge

![Health badge](/badges/m1guelpf-eloquent-immutable/health.svg)

```
[![Health](https://phpackages.com/badges/m1guelpf-eloquent-immutable/health.svg)](https://phpackages.com/packages/m1guelpf-eloquent-immutable)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k116.5M113](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[pgvector/pgvector

pgvector support for PHP

198628.3k10](/packages/pgvector-pgvector)

PHPackages © 2026

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