PHPackages                             dive-be/eloquent-utils - 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. dive-be/eloquent-utils

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

dive-be/eloquent-utils
======================

Declarative Eloquent utilities for an improved DX

0.4.0(1y ago)59.8k↓30.8%MITPHPPHP ~8.4

Since May 23Pushed 1y agoCompare

[ Source](https://github.com/dive-be/eloquent-utils)[ Packagist](https://packagist.org/packages/dive-be/eloquent-utils)[ Docs](https://github.com/dive-be/eloquent-utils)[ RSS](/packages/dive-be-eloquent-utils/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (6)Dependencies (2)Versions (7)Used By (0)

🛠 Eloquent utilities for improved DX
====================================

[](#-eloquent-utilities-for-improved-dx)

[![Latest Version on Packagist](https://camo.githubusercontent.com/184390aab5d5c67a0ff8e20c488096939947ffd3ac21df0b089f041cdb59f7d4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646976652d62652f656c6f7175656e742d7574696c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dive-be/eloquent-utils)

This package is a collection of declarative tools for common `Eloquent` tasks.

- [DisablesTimestamps](#disablestimestamps)
- [InteractsWithStaticData](#interactswithstaticdata)
- [Unguarded](#unguarded)
- [Unwritable](#unwritable)

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

[](#installation)

You can install the package via composer:

```
composer require dive-be/eloquent-utils
```

Usage
-----

[](#usage)

Again, the primary purpose is to provide a **declarative** interface for frequent **imperative** tasks. The added benefit is that a person skimming through the model can immediately see what's going on due to the declarative nature.

### DisablesTimestamps

[](#disablestimestamps)

Disables the `created_at` and `updated_at` auto-updates.

```
class Country extends Model
{
    use \Dive\Eloquent\DisablesTimestamps;
}
```

### InteractsWithStaticData

[](#interactswithstaticdata)

> Depends on: DisablesTimestamps, Unwritable

Prevent unnecessary database round-trips by caching each and every record next to your static model.

#### Migration

[](#migration)

Define a unique column.

```
Schema::create('languages', static function (Blueprint $table) {
    $table->id();
    $table->char('iso', 2)->unique();
});
```

#### Model

[](#model)

The source data is defined in the **same file**.

```
final class Language extends Model
{
    use \Dive\Eloquent\InteractsWithStaticData;
}

Language::$source = [
    'DE' => ['id' => 1, 'iso' => 'DE'],
    'EN' => ['id' => 2, 'iso' => 'EN'],
    'FR' => ['id' => 3, 'iso' => 'FR'],
    'NL' => ['id' => 4, 'iso' => 'NL'],
];
```

#### (Database)Seeder

[](#databaseseeder)

```
public function run(ConnectionInterface $db)
{
    $db->table('languages')->insert(Language::$source);
}
```

#### Use

[](#use)

No database queries will be performed...

```
Language::find('NL'); // App\Models\Language { #3645 }
```

### Unguarded

[](#unguarded)

Disables [mass assignment protection](https://laravel.com/docs/9.x/eloquent#mass-assignment) on a **per model basis**.

```
class Product extends Model
{
    use \Dive\Eloquent\Unguarded;
}
```

```
Product::find(1337)->fill([
    'sku' => 'abcdefg',
])->save(); // true
```

### Unwritable

[](#unwritable)

Makes your Eloquent model read-only.

```
class Coupon extends Model
{
    use \Dive\Eloquent\Unwritable;
}
```

```
Coupon::find(10)->update(['code' => 'je-suis-rogue']); // BadMethodCallException
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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)

- [Muhammed Sari](https://github.com/mabdullahsari)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance45

Moderate activity, may be stable

Popularity28

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~215 days

Recently: every ~269 days

Total

6

Last Release

425d ago

PHP version history (4 changes)0.1.0PHP ^8.1

0.2.0PHP ~8.2

0.3.0PHP ~8.3

0.4.0PHP ~8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/59749?v=4)[Artem Loenko](/maintainers/dive)[@dive](https://github.com/dive)

---

Top Contributors

[![mabdullahsari](https://avatars.githubusercontent.com/u/24608797?v=4)](https://github.com/mabdullahsari "mabdullahsari (7 commits)")

---

Tags

eloquentutilitiessupportdeclarativedive

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/dive-be-eloquent-utils/health.svg)

```
[![Health](https://phpackages.com/badges/dive-be-eloquent-utils/health.svg)](https://phpackages.com/packages/dive-be-eloquent-utils)
```

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.4M96](/packages/mongodb-laravel-mongodb)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k32.6M46](/packages/kirschbaum-development-eloquent-power-joins)[owen-it/laravel-auditing

Audit changes of your Eloquent models in Laravel

3.4k36.8M157](/packages/owen-it-laravel-auditing)[spatie/laravel-sluggable

Generate slugs when saving Eloquent models

1.6k12.9M311](/packages/spatie-laravel-sluggable)[watson/validating

Eloquent model validating trait.

9803.5M54](/packages/watson-validating)[cybercog/laravel-love

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

1.2k332.0k1](/packages/cybercog-laravel-love)

PHPackages © 2026

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