PHPackages                             laravel-ready/model-support - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. laravel-ready/model-support

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

laravel-ready/model-support
===========================

Useful model support traits

v3.0.1(5mo ago)42.7k↓50%1MITPHPPHP ^8.5 || ^8.4 || ^8.3 || ^8.2 || ^8.1CI passing

Since Apr 9Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/laravel-ready/model-support)[ Packagist](https://packagist.org/packages/laravel-ready/model-support)[ RSS](/packages/laravel-ready-model-support/feed)WikiDiscussions main Synced 1mo ago

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

ModelSupport
============

[](#modelsupport)

[![ModelSupport](https://camo.githubusercontent.com/15f5ec090ee62de4086a492a3f2cfc87079679f1fec800c0363224a8da4dfb1a/68747470733a2f2f707265766965772e647261676f6e2d636f64652e70726f2f4c61726176656c52656164792f6d6f64656c2d737570706f72742e7376673f6272616e643d6c61726176656c)](https://github.com/laravel-ready/model-support)

[![Tests](https://camo.githubusercontent.com/b6fe930836750ed39376ae6591b515b011181d8838304be716b24afc02f4e18c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c61726176656c2d72656164792f6d6f64656c2d737570706f72742f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/laravel-ready/model-support/actions)[![Stable Version](https://camo.githubusercontent.com/8071e642c23b94ed13ed2c5959908f1aa7e9ad5781b9aa1247de384e9c1deba2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6c61726176656c2d72656164792f6d6f64656c2d737570706f72743f6c6162656c3d737461626c65267374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-ready/model-support)[![Total Downloads](https://camo.githubusercontent.com/0eb1bb623b061dbab6e06f04f124167e1b7c970098e65aa9d776f3be81ec07ec/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c61726176656c2d72656164792f6d6f64656c2d737570706f72742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-ready/model-support)[![License](https://camo.githubusercontent.com/e899286de92a556668ccbe537cd99e167f9ecc5416ad21e3ec43a66adf4aeacb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c61726176656c2d72656164792f6d6f64656c2d737570706f72742e7376673f7374796c653d666c61742d737175617265)](LICENSE)

📂 About
-------

[](#-about)

Useful eloquent model support traits.

📦 Installation
--------------

[](#-installation)

Get via composer

```
composer require laravel-ready/model-support
```

⚙️ Configs
----------

[](#️-configs)

```
php artisan vendor:publish --tag=model-support-config
```

Example Trait Usage
-------------------

[](#example-trait-usage)

```
use LaravelReady\ModelSupport\Traits\Sluggable;
use LaravelReady\ModelSupport\Traits\HasActive;
...

class Post extends Model
{
    use Sluggable, HasActive;

    protected $fillable = [
        'title',
        'slug',
        'content',
        'is_active'
    ];

    ...
}
```

📝 Usage
-------

[](#-usage)

### HasLanguage

[](#haslanguage)

This trait allows you to get models by language.

> **Note**Field name is `lang` by default. You can change it in the config file.

```
use LaravelReady\ModelSupport\Traits\HasLanguage;
...

$model->lang('en'); // will return $query->where('lang', $lang);
$model->langNot('en'); // will return $query->where('lang', '!=', $lang);
$model->langIn(['en', 'tr']); // will return $query->whereIn('lang', $langs);
$model->langNotIn(['en', 'tr']); // will return $query->whereNotIn('lang', $langs);
```

### Sluggable

[](#sluggable)

This trait allows you to generate a slug from a string. When you create a new model, the slug will be generated automatically. If you change the title, the slug will also be updated. See [bootSluggable()](src/Traits/Sluggable.php#L10) method for more details.

> **Note**Field names are `slug` and `title` by default. You can change it in the config file.

```
use LaravelReady\ModelSupport\Traits\Sluggable;
...

$model->slug('any-string'); // will return $query->where('slug', $slug);
$model->slugLike('any-string'); // will return $query->where('slug', 'like', $slug);
$model->slugNot('any-string'); // will return $query->where('slug', '!=', $slug);
$model->slugNotLike('any-string'); // will return $query->where('slug', 'not like', $slug);
$model->slugIn(['any-string', 'any-string']); // will return $query->whereIn('slug', $slug);
$model->slugNotIn(['any-string', 'any-string']); // will return $query->whereNotIn('slug', $slug);
```

### SluggableTitle

[](#sluggabletitle)

This trait allows you to generate a slug from a title field. Same as [Sluggable](#sluggable) trait but it only works with the title field.

> **Note**Field names are `slug` and `title` (hardcoded, not configurable).

```
use LaravelReady\ModelSupport\Traits\SluggableTitle;
...

$model->slug('any-string'); // will return $query->where('slug', $slug);
$model->slugLike('any-string'); // will return $query->where('slug', 'like', $slug);
$model->slugNot('any-string'); // will return $query->where('slug', '!=', $slug);
$model->slugNotLike('any-string'); // will return $query->where('slug', 'not like', $slug);
$model->slugIn(['any-string', 'any-string']); // will return $query->whereIn('slug', $slug);
$model->slugNotIn(['any-string', 'any-string']); // will return $query->whereNotIn('slug', $slug);
```

### SluggableName

[](#sluggablename)

This trait allows you to generate a slug from a name field. Same as [Sluggable](#sluggable) trait but it only works with the name field.

> **Note**Field names are `slug` and `name` (hardcoded, not configurable).

```
use LaravelReady\ModelSupport\Traits\SluggableName;
...

$model->slug('any-string'); // will return $query->where('slug', $slug);
$model->slugLike('any-string'); // will return $query->where('slug', 'like', $slug);
$model->slugNot('any-string'); // will return $query->where('slug', '!=', $slug);
$model->slugNotLike('any-string'); // will return $query->where('slug', 'not like', $slug);
$model->slugIn(['any-string', 'any-string']); // will return $query->whereIn('slug', $slug);
$model->slugNotIn(['any-string', 'any-string']); // will return $query->whereNotIn('slug', $slug);
```

### ParentChild

[](#parentchild)

This trait allows you to work with parent-child relationships in self-referencing models.

> **Note**Field name is `parent_id` by default. You can change it in the config file.

> **Warning**It's only supports self-referencing models.

```
use LaravelReady\ModelSupport\Traits\ParentChild;
...

$model->parent(); // will return parent model (BelongsTo relationship)
$model->children(); // will return children models (HasMany relationship)
$model->recursiveParent(); // will return parent with all recursive parents
$model->recursiveChildren(); // will return children with all recursive children
$model->recursiveParentAndChildren(); // will return parent and children recursively
```

### HasActive

[](#hasactive)

This trait allows you to get active/inactive status models.

> **Note**Field name is `is_active` by default. You can change it in the config file.

> **Warning**This trait forces your models to fillable `is_active` field and adds `is_active` cast to `boolean`.

```
use LaravelReady\ModelSupport\Traits\HasActive;
...

$model->status(true|false); // will return $query->where('is_active', $status);
$model->active(); // will return $query->where('is_active', true);
$model->inactive(); // will return $query->where('is_active', false);
```

🧪 Testing
---------

[](#-testing)

This package uses [Pest PHP](https://pestphp.com/) for testing and is tested across multiple PHP and Laravel versions.

### Running Tests

[](#running-tests)

```
# Run all tests
composer test

# Run tests with coverage
composer test:coverage

# Run tests with HTML coverage report
composer test:coverage:html
```

### Static Analysis

[](#static-analysis)

```
# Run PHPStan analysis
composer test:styles

# Run PHPStan with pro features (fix & watch)
composer test:styles:pro
```

### Test Matrix

[](#test-matrix)

The package is automatically tested against:

PHP VersionLaravel 10.xLaravel 11.xLaravel 12.x8.1✅❌❌8.2✅✅❌8.3✅✅✅8.4✅✅✅8.5❌❌✅Tests run automatically on every push and pull request via [GitHub Actions](.github/workflows/tests.yml).

### Local Testing

[](#local-testing)

By using **[act](https://github.com/nektos/act)** you can run all test matrix locally (*requires [Docker](https://www.docker.com/)*).

```
act
```

⚓ Credits
---------

[](#-credits)

- This project was generated by the **[packager](https://github.com/laravel-ready/packager)**.

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance74

Regular maintenance activity

Popularity23

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity70

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

Recently: every ~234 days

Total

14

Last Release

170d ago

Major Versions

v1.0.12 → v2.0.02024-05-27

v2.0.0 → v3.0.02025-11-30

PHP version history (3 changes)1.0.0PHP ^8.1

v2.0.0PHP ^8.2 || ^8.1

v3.0.0PHP ^8.5 || ^8.4 || ^8.3 || ^8.2 || ^8.1

### Community

Maintainers

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

---

Top Contributors

[![relliv](https://avatars.githubusercontent.com/u/17010054?v=4)](https://github.com/relliv "relliv (52 commits)")

---

Tags

laravellaravel-modellaravel-model-supportmodel-supportlaravelmodeltraitsupportmodel support

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/laravel-ready-model-support/health.svg)

```
[![Health](https://phpackages.com/badges/laravel-ready-model-support/health.svg)](https://phpackages.com/packages/laravel-ready-model-support)
```

###  Alternatives

[adamhopkinson/laravel-model-hash

A trait which automatically generates a unique hash per model instance

2318.7k](/packages/adamhopkinson-laravel-model-hash)

PHPackages © 2026

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