PHPackages                             macsidigital/laravel-eloquent-extended - 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. macsidigital/laravel-eloquent-extended

ActiveLibrary

macsidigital/laravel-eloquent-extended
======================================

Eloquent extended is a library to add some additional functions to laravel eloquent

4.0.0(1y ago)0141PHPPHP ^8.1|^8.2|^8.3|^8.4CI failing

Since Feb 12Pushed 1y ago1 watchersCompare

[ Source](https://github.com/MacsiDigital/laravel-eloquent-extended)[ Packagist](https://packagist.org/packages/macsidigital/laravel-eloquent-extended)[ Docs](https://github.com/macsidigital/laravel-eloquent-extended)[ GitHub Sponsors](https://github.com/MacsiDigital)[ RSS](/packages/macsidigital-laravel-eloquent-extended/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (19)Used By (0)

Laravel Eloquent Extended
=========================

[](#laravel-eloquent-extended)

Extended model attributes, Mulit Language attributes and Slugs
--------------------------------------------------------------

[](#extended-model-attributes-mulit-language-attributes-and-slugs)

[![Header Image](https://github.com/MacsiDigital/repo-design/raw/master/laravel-eloquent-extended/header.png)](https://github.com/MacsiDigital/repo-design/raw/master/laravel-eloquent-extended/header.png)

 [![tests badge](https://github.com/MacsiDigital/laravel-eloquent-extended/workflows/Tests/badge.svg)](https://github.com/MacsiDigital/laravel-eloquent-extended/actions?query=workflow%3ATests) [![version badge](https://camo.githubusercontent.com/7bd3f53477a1e0bbdae21ed447c450f932d723133b82f60ef44b2bbc684824cf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d616373696469676974616c2f6c61726176656c2d656c6f7175656e742d657874656e6465642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/macsidigital/laravel-eloquent-extended) [![downloads badge](https://camo.githubusercontent.com/dac824f4748877ac4f99af06f5886790745f96e98fd9094882e610893b8b0cc5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d616373696469676974616c2f6c61726176656c2d656c6f7175656e742d657874656e6465642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/macsidigital/laravel-eloquent-extended)

Extended Eloquent Models, mainly for JSON and Multi Language Content

Support us
----------

[](#support-us)

We invest a lot in creating [open source packages](https://macsidigital.co.uk/open-source), and would be grateful for a [sponsor](https://github.com/sponsors/MacsiDigital) if you make money from your product that uses them.

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

[](#installation)

You can install the package via composer:

```
composer require macsidigital/laravel-eloquent-extended
```

Usage
-----

[](#usage)

To use extended we just need to add the trait and add a protected extendedAttributes variable like so

```
use Extended\Traits\IsExtended;
use Illuminate\Database\Eloquent\Model;

class TestExtendedModel extends Model
{
	use IsExtended;

	protected $extendedAttributes = [
		'test_field',
	];

}
```

Once set it will act like a normal field

```
$test = new model;
$test->test_field = 'something';

echo $test->test_field;
```

### Content

[](#content)

To use content is similar with the exception that we can set languages

```
use Extended\Traits\IsExtended;
use Extended\Traits\HasContent;
use Illuminate\Database\Eloquent\Model;

class TestExtendedModel extends Model
{
	use IsExtended, HasContent;

	protected $contentAttributes = [
		'test_content_field',
	];

}
```

Once set it will act like a normal field

```
$test = new model;
$test->test_content_field = 'something';

echo $test->test_content_field;
```

We can set and get different languages like so

```
$test = new model;
$test->test_content_field = 'something';

$test->setContentLanguage('de');

$test->test_content_field = 'something DE';

$test->setContentLanguage('en');

echo $test->test_content_field; // 'something'

$test->setContentLanguage('de');

echo $test->test_content_field; // 'something DE'
```

### Slugs

[](#slugs)

We can use Multiple Language Slugs by adding both HasContent and HasSlug traits and setting the slug fields.

```
use Extended\Traits\HasSlug;
use Extended\Traits\IsExtended;
use Extended\Traits\HasContent;
use Illuminate\Database\Eloquent\Model;

class TestExtendedModel extends Model
{
	use IsExtended, HasContent, HasSlug;

	protected $contentAttributes = [
		'uri',
	];

	protected $findSlugField = 'extended->uri';
	protected $slugField = 'uri';

}
```

You can then add the uri like so

```
$test = new model;
$test->uri = 'something';

echo $test->uri; //esomething
```

To ensure there are no duplicate slugs you can use the method createSlug like so

```
$test = new model;
$test->createSlug('Test Something');

echo $test->uri; //test-something

$test = new model;
$test->createSlug('Test Something');

echo $test->uri; //test-something-h58s
```

We can set and get different languages like so

```
$test = new model;
$test->uri = 'something';

$test->setLanguage('de');

$test->uri = 'something-de';

$test->setMetaLanguage('en');

echo $test->uri; // 'something'

$test->setMetaLanguage('de');

echo $test->uri; // 'something-de'
```

We can then retrieve by the slug with the withSlug scoped query method

```
$test = new model;
$test->createSlug('something');

$model = model::withSlug('something')->first()

echo $model->uri; // 'something'
```

There is also a reversed function to get all models without the slug

```
$test = new model;
$test->createSlug('something');

$test = new model;
$test->createSlug('something-1234');

$model = model::withoutSlug('something')->first()

echo $model->uri; // 'something-1234'
```

We can also use slugs outside of the multi language scope, just set to a normal database field.

```
use Extended\Traits\HasSlug;
use Extended\Traits\IsExtended;
use Extended\Traits\HasContent;
use Illuminate\Database\Eloquent\Model;

class TestExtendedModel extends Model
{
	use HasSlug;

	protected $findSlugField = 'uri';
	protected $slugField = 'uri';

}
```

Then all functions will work as previous

### Route Model Binding

[](#route-model-binding)

You can use {item:slug} in routes to automatically retrieve items by their slug. Just remember to Typehint the model in the controller/Route action.

Testing
-------

[](#testing)

We have a test suite testing our implementations, to use just run phpunit

```
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)

- [Colin Hall](https://github.com/colinhall17)
- [MacsiDigital](https://github.com/MacsiDigital)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance44

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 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 ~108 days

Recently: every ~277 days

Total

18

Last Release

443d ago

Major Versions

1.3.0 → 2.0.02022-02-08

2.1.1 → 3.0.02024-06-13

3.0.0 → 4.0.02025-02-24

PHP version history (6 changes)1.0.0PHP ^7.3

1.3.0PHP ^7.4|^8.0

2.0.1PHP ^8.0

2.1.0PHP ^8.1

3.0.0PHP ^8.1|^8.2

4.0.0PHP ^8.1|^8.2|^8.3|^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/134dcd0c87f691d2f351f4bff03eb390871de1992f1a79ecf034b4ac53b4ca71?d=identicon)[MacsiDigital](/maintainers/MacsiDigital)

---

Top Contributors

[![colinhall17](https://avatars.githubusercontent.com/u/5073205?v=4)](https://github.com/colinhall17 "colinhall17 (30 commits)")

---

Tags

macsidigitallaravel-eloquent-extended

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/macsidigital-laravel-eloquent-extended/health.svg)

```
[![Health](https://phpackages.com/badges/macsidigital-laravel-eloquent-extended/health.svg)](https://phpackages.com/packages/macsidigital-laravel-eloquent-extended)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[namu/wirechat

A Laravel Livewire messaging app for teams with private chats and group conversations.

54324.5k](/packages/namu-wirechat)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135192.6k5](/packages/statamic-rad-pack-runway)

PHPackages © 2026

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