PHPackages                             saritasa/eloquent-custom - 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. saritasa/eloquent-custom

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

saritasa/eloquent-custom
========================

Saritasa customizations for Eloquent

1.2.0(3y ago)012.3k2[1 issues](https://github.com/Saritasa/php-eloquent-custom/issues)1MITPHPPHP &gt;=7.0

Since Apr 12Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Saritasa/php-eloquent-custom)[ Packagist](https://packagist.org/packages/saritasa/eloquent-custom)[ RSS](/packages/saritasa-eloquent-custom/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (6)Versions (15)Used By (1)

Eloquent Extensions and Helpers
===============================

[](#eloquent-extensions-and-helpers)

[![PHP CodeSniffer](https://github.com/Saritasa/php-eloquent-custom/workflows/PHP%20Codesniffer/badge.svg)](https://github.com/Saritasa/php-eloquent-custom/actions)[![Release](https://camo.githubusercontent.com/cff3e79cf6034264446a7ddff8ea44aac7b74ad30a2126b4d0a4aa9234c37748/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f73617269746173612f7068702d656c6f7175656e742d637573746f6d2e737667)](https://github.com/Saritasa/php-eloquent-custom/releases)[![PHPv](https://camo.githubusercontent.com/ad81871b7909dff48979b14394cfd3107dc87fae13d236b37e0d8f1005f8511d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f73617269746173612f656c6f7175656e742d637573746f6d2e737667)](http://www.php.net)[![Downloads](https://camo.githubusercontent.com/17ec5a920763f5b33561af6b413350e13cfcb91d8686ae4f24179bcc9824b029/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73617269746173612f656c6f7175656e742d637573746f6d2e737667)](https://packagist.org/packages/saritasa/eloquent-custom)

Custom Extensions for Eloquent

See

Laravel 5.x/6.x
---------------

[](#laravel-5x6x)

Install the `saritasa/eloquent-custom` package:

```
$ composer require saritasa/eloquent-custom
```

**Optionally** (*if you want to use default migrations*): If you use Laravel 5.4 or less, or 5.5+ with [package discovery](https://laravel.com/docs/5.5/packages#package-discovery) disabled, add the PredefinedMigrationsServiceProvider service provider `config/app.php`:

```
'providers' => array(
    // ...
    Saritasa\Database\Eloquent\PredefinedMigrationsServiceProvider::class,
)
```

then you can execute command:

```
php artisan vendor:publish --provider=Saritasa\Database\Eloquent\PredefinedMigrationsServiceProvider --tag=migrations
```

Available classes
-----------------

[](#available-classes)

### Entity

[](#entity)

Extends Eloquent model, adds:

- Ability to set default field values for newly created inheritors

**Example**:

```
class User extends Entity
{
    protected $defaults = [
        'role' => 'user'
    ]
}
```

now if you create new user it will have role 'user' by default, if you don't provide it explicitly:

```
$user = new User(['name' => 'John Doe']);
$this->assertEquals('user', $user->role); // true

$admin = new User['name' => 'Mary', 'role' => 'admin');
$this->assertEquals('admin', $admin->role); // true
```

### SortByName

[](#sortbyname)

Global scope for Eloquent models to add sorting by name by default

**Example**:

```
class SomeModel extends Model {
...
    protected static function boot()
    {
        parent::boot();
        static::addGlobalScope(new \Saritasa\Database\Eloquent\Scopes\SortByName());
    }
...
}
```

### CamelCaseModel

[](#camelcasemodel)

Extended class Model for use camel case notation in DB.

**Example**:

```
use Saritasa\Database\Eloquent\Models\CamelCaseModel;

class SomeModel extends CamelCaseModel
{
    //your code
}
```

### CamelCaseForeignKeys trait

[](#camelcaseforeignkeys-trait)

Use in any model class for get the default foreign key name for this model. By default, Eloquent gets foreign keys in snake case notation, this trait swap notation to camel case like `carModelId` instead of `car_model_id`. Use it if you already have foreign keys in camel case notation.

**Example**:

```
use Saritasa\Database\Eloquent\Models\CamelCaseForeignKeys;

class MyModel extends SomeModelClass
{
    use CamelCaseForeignKeys;
}
```

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

[](#contributing)

See [CONTRIBUTING](CONTRIBUTING.md) and [Code of Conduct](CONDUCT.md), if you want to make contribution (pull request) or just build and test project on your own.

Resources
---------

[](#resources)

- [Changes History](CHANGES.md)
- [Bug Tracker](http://github.com/saritasa/php-eloquent-custom/issues)
- [Authors](http://github.com/saritasa/php-eloquent-custom/contributors)

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 77.8% 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 ~147 days

Recently: every ~202 days

Total

14

Last Release

1443d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b7632cf2eb5dd552ace9d66947ed6919e19c6a2fdb5dc73b8c71e0f9886ccc83?d=identicon)[saritasa](/maintainers/saritasa)

---

Top Contributors

[![populov](https://avatars.githubusercontent.com/u/3766033?v=4)](https://github.com/populov "populov (56 commits)")[![RuslanOlontsev](https://avatars.githubusercontent.com/u/107931869?v=4)](https://github.com/RuslanOlontsev "RuslanOlontsev (10 commits)")[![hollow-en](https://avatars.githubusercontent.com/u/87475798?v=4)](https://github.com/hollow-en "hollow-en (4 commits)")[![maxermolenko](https://avatars.githubusercontent.com/u/11438109?v=4)](https://github.com/maxermolenko "maxermolenko (2 commits)")

---

Tags

eloquentlaravelphplaraveleloquent

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/saritasa-eloquent-custom/health.svg)

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

###  Alternatives

[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k29.9M42](/packages/kirschbaum-development-eloquent-power-joins)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.0M88](/packages/mongodb-laravel-mongodb)[spatie/laravel-health

Monitor the health of a Laravel application

87411.3M154](/packages/spatie-laravel-health)[spatie/laravel-sluggable

Generate slugs when saving Eloquent models

1.5k12.4M294](/packages/spatie-laravel-sluggable)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[watson/validating

Eloquent model validating trait.

9733.4M53](/packages/watson-validating)

PHPackages © 2026

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