PHPackages                             sfneal/models - 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. sfneal/models

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

sfneal/models
=============

Eloquent Model wrapper with extended functionality

4.1.0(1y ago)198.0k[1 issues](https://github.com/sfneal/models/issues)[3 PRs](https://github.com/sfneal/models/pulls)9MITPHPPHP ^8.1CI passing

Since Aug 13Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/sfneal/models)[ Packagist](https://packagist.org/packages/sfneal/models)[ Docs](https://github.com/sfneal/models)[ RSS](/packages/sfneal-models/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (50)Used By (9)

Eloquent Models - extended
==========================

[](#eloquent-models---extended)

[![Packagist PHP support](https://camo.githubusercontent.com/ba699215f7b2e9b2e82f79c4f60f1bdc9710669e289815b66a620191bc4d422e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f73666e65616c2f6d6f64656c73)](https://packagist.org/packages/sfneal/models)[![Latest Version on Packagist](https://camo.githubusercontent.com/69a5f84f620f5c567b2bc2c1533e7b794bffaefbf1999bd44c27114c287bc519/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73666e65616c2f6d6f64656c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sfneal/models)[![Build Status](https://camo.githubusercontent.com/3e2ceb02cb11f3019515ead98806004c2001306fd2000a369a87f4627e27d371/68747470733a2f2f7472617669732d63692e636f6d2f73666e65616c2f6d6f64656c732e7376673f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://travis-ci.com/sfneal/models)[![Quality Score](https://camo.githubusercontent.com/406da9456874e85f2af1a40e7e8cd92a4d2658e328d7a374f00647241ec31c52/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f73666e65616c2f6d6f64656c732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/sfneal/models)[![Total Downloads](https://camo.githubusercontent.com/a5838f28e4cc8bce5624ff3a44b8cf6f9ac5891fb512a20f6e8f04dd2b546f7a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73666e65616c2f6d6f64656c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sfneal/models)

Eloquent Model wrapper with extended functionality.

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

[](#installation)

You can install the package via composer:

```
composer require sfneal/models
```

Usage
-----

[](#usage)

### Models

[](#models)

`AbstractModel`, `AbstractPivot`, &amp; `AbstractAuthenticatable` can be used as parent classes the same way Eloquent's `Model`, `Pivot` &amp; `Authenticatable` can be used. `AbstractModel` uses `Sfneal\Builders\QueryBuilder` as the default Eloquent Query Builder (see [sfneal/builders](https://packagist.org/packages/sfneal/models).

```
class YourModel extends AbstractModel
{
    protected $table = 'your_model';
    protected $primaryKey = 'your_model_id';

    protected $fillable = [
        'your_model_id',
        //
    ];
}
```

Models that extend the `AbstractModel` class will have access to a variety of public access to a variety of methods that extends many of `Models` existing functionality's.

- 'Newness' - methods to detetmine if a Model is new (useful for apps with CMS) or how new a model is
- 'Changed' - methods to check if a Model was recently created, updated, deleted or unchanged

```
// Create a new Model record
$model = YourModel::query()->create($data);

// returns true
$model->wasCreated();

// Update the Model
$model->update([
	'some_attribute' => 'blue'
]);

// returns false
$model->wasCreated();

// returns true
$model->wasUpdated();
```

### Builders

[](#builders)

Add the custom QueryBuilder to any Eloquent model by overwriting the built-in newEloquentBuilder() &amp; query() methods.

```
use Illuminate\Database\Eloquent\Builder;
use Sfneal\Builders\QueryBuilder;

class ExampleModel extends Model
{
    /**
     * Query Builder.
     *
     * @param $query
     * @return QueryBuilder
     */
    public function newEloquentBuilder($query)
    {
        return new QueryBuilder($query);
    }

    /**
     * Query Builder method for improved type hinting.
     *
     * @return QueryBuilder|Builder
     */
    public static function query()
    {
        return parent::query();
    }
}
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information 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)

- [Stephen Neal](https://github.com/sfneal)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

PHP Package Boilerplate
-----------------------

[](#php-package-boilerplate)

This package was generated using the [PHP Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 97.5% 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 ~33 days

Recently: every ~43 days

Total

46

Last Release

593d ago

Major Versions

0.6.0 → 1.0.02021-01-28

1.4.0 → 2.0.02021-04-06

2.10.0 → 3.0.02024-03-29

3.0.4 → 4.0.02024-05-01

PHP version history (8 changes)0.1.0PHP ^7.1

0.2.1PHP ^7.2

0.3.0PHP &gt;=7.0

0.5.0PHP &gt;=7.1

0.6.0PHP &gt;=7.3

2.8.2PHP ^7.3|^8.0

3.0.0PHP ^8.0

4.1.0PHP ^8.1

### Community

Maintainers

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

---

Top Contributors

[![sfneal](https://avatars.githubusercontent.com/u/23200215?v=4)](https://github.com/sfneal "sfneal (311 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")

---

Tags

modelssfneal

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sfneal-models/health.svg)

```
[![Health](https://phpackages.com/badges/sfneal-models/health.svg)](https://phpackages.com/packages/sfneal-models)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11120.2M21](/packages/anourvalar-eloquent-serialize)[mtolhuys/laravel-schematics

A interface to help you build your models

1.5k84.3k1](/packages/mtolhuys-laravel-schematics)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135192.6k5](/packages/statamic-rad-pack-runway)[mopo922/laravel-treats

A collection of goodies for Laravel 5.

108451.6k1](/packages/mopo922-laravel-treats)[gearbox-solutions/eloquent-filemaker

A package for getting FileMaker records as Eloquent models in Laravel

6454.8k2](/packages/gearbox-solutions-eloquent-filemaker)[10quality/wp-query-builder

Wordpress Query Builder class library for custom models and data querying.

4012.2k](/packages/10quality-wp-query-builder)

PHPackages © 2026

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