PHPackages                             snowpenguinstudios/laravel-model-status - 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. snowpenguinstudios/laravel-model-status

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

snowpenguinstudios/laravel-model-status
=======================================

This Laravel package allows the ability to implement a status feature to any Laravel model. This utilizes the polymorphic relationships.

v1.1.0(4y ago)15MITPHPPHP ^7.3|^8.0

Since Sep 14Pushed 4y ago1 watchersCompare

[ Source](https://github.com/SnowPenguinStudios/laravel-model-status)[ Packagist](https://packagist.org/packages/snowpenguinstudios/laravel-model-status)[ Docs](https://github.com/snowpenguinstudios/laravel-model-status)[ GitHub Sponsors](https://github.com/SnowPenguinStudios)[ RSS](/packages/snowpenguinstudios-laravel-model-status/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (5)Versions (3)Used By (0)

Snow Penguin Studios - Laravel Model Status
===========================================

[](#snow-penguin-studios---laravel-model-status)

[![Latest Version on Packagist](https://camo.githubusercontent.com/90ebb9b9249c603a58a3da9743d0ecb0211063a5f167f513deea900034682bc4/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f762f736e6f7770656e6775696e73747564696f732f6c61726176656c2d6d6f64656c2d737461747573)](https://packagist.org/packages/snowpenguinstudios/laravel-model-status)[![Total Downloads](https://camo.githubusercontent.com/a2300f25a1c23f0fdfca42bb5d728c3917c6c34d2a3f9ab1c51cbe594bb243cd/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f64742f736e6f7770656e6775696e73747564696f732f6c61726176656c2d6d6f64656c2d7374617475733f636f6c6f723d626c7565)](https://packagist.org/packages/snowpenguinstudios/laravel-model-status)[![Package Contributors](https://camo.githubusercontent.com/56c88b2d45a160d63c38d12ac6d35396f81021273a1c5d5402e99247488351fd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f736e6f7770656e6775696e73747564696f732f6c61726176656c2d6d6f64656c2d7374617475733f636f6c6f723d626c7565)](../../contributors)[![Package License](https://camo.githubusercontent.com/bb1dd1a98b6d76cbdae7109030417cef66dcfcbdaf347325292a4f99ffe252c1/68747470733a2f2f62616467656e2e6e65742f6769746875622f6c6963656e73652f736e6f7770656e6775696e73747564696f732f6c61726176656c2d6d6f64656c2d737461747573)](License.md)

[![GitHub Tests Action Status](https://camo.githubusercontent.com/c61a64b648f22312759bc7ae61745fda90889daee9a4b42ddcbc8476e0f757ae/68747470733a2f2f62616467656e2e6e65742f6769746875622f636865636b732f736e6f7770656e6775696e73747564696f732f6c61726176656c2d6d6f64656c2d7374617475732f6d61737465722f746573743f6c6162656c3d7465737473)](https://github.com/snowpenguinstudios/laravel-model-status/actions?query=workflow%3Arun-tests+branch%3Amaster)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/47246d9c506f205ba027399c75d1c31ca4c0fa29c7543d4693606ba1686bd689/68747470733a2f2f62616467656e2e6e65742f6769746875622f636865636b732f736e6f7770656e6775696e73747564696f732f6c61726176656c2d6d6f64656c2d7374617475732f6d61737465723f6c6162656c3d636f64652532307374796c65)](https://github.com/snowpenguinstudios/laravel-model-status/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amaster)[![Package Last Commit](https://camo.githubusercontent.com/27c3a36a245362a2842e4b70cba5477f697ebe295bac1b443ec87b496376e992/68747470733a2f2f62616467656e2e6e65742f6769746875622f6c6173742d636f6d6d69742f736e6f7770656e6775696e73747564696f732f6c61726176656c2d6d6f64656c2d737461747573)](https://camo.githubusercontent.com/27c3a36a245362a2842e4b70cba5477f697ebe295bac1b443ec87b496376e992/68747470733a2f2f62616467656e2e6e65742f6769746875622f6c6173742d636f6d6d69742f736e6f7770656e6775696e73747564696f732f6c61726176656c2d6d6f64656c2d737461747573)

---

This Laravel package allows the ability to implement a status feature to any Laravel model. This utilizes the polymorphic relationships. The package features includes:

- Setting and updating status on any model with a `status_id` field.
- Store status change history as status updates.
- Ability to assign statuses to be available to specific models. A status can be available for all models or one model.

---

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

[](#installation)

You can install the package via composer:

```
composer require snowpenguinstudios/laravel-model-status
```

You can publish and run the migrations with:

```
php artisan vendor:publish --provider="SnowPenguinStudios\LaravelModelStatus\LaravelModelStatusServiceProvider" --tag="laravel-model-status-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --provider="SnowPenguinStudios\LaravelModelStatus\LaravelModelStatusServiceProvider" --tag="laravel-model-status-config"
```

This is the contents of the published config file:

```
return [
];
```

Model Setup
-----------

[](#model-setup)

### Add status\_id to the model table

[](#add-status_id-to-the-model-table)

```
Schema::table('table-name', function (Blueprint $table) {
    $table->foreignId('status_id');
});
```

### Add HasStatus Trait to model

[](#add-hasstatus-trait-to-model)

```
use SnowPenguinStudios\LaravelModelStatus\Traits\HasStatus;

class ModelName extends Model {
    use HasStatus;

    ...
}
```

Usage
-----

[](#usage)

### Working With The Status Model

[](#working-with-the-status-model)

The following attributes are allowed to be set for mass assignment: `model`, `name`, `description`, `is_default`, `is_active` and `order`.

Creating a global status:

```
use SnowPenguinStudios\LaravelModelStatus\Models\Status;
$status = Status::create([
    'name' => 'New',
    'is_active' => true
]);
```

Creating a new model-specific status:

```
use SnowPenguinStudios\LaravelModelStatus\Models\Status;
$status = Status::create([
    'name' => 'New',
    'model' => ModelName::class,
    'is_active' => true
]);
```

### Assigning Status To Model

[](#assigning-status-to-model)

```
...
$model->status_id = $status->id;
...
$model->save();
```

**OR**

```
// This will work for create() as well...
$model->update([
    ...
    'status_id' => $status->id,
    ...
]);
```

### Getting a Models Available Statuses

[](#getting-a-models-available-statuses)

Provides an array of all statuses (including the statues not assigned to a model) available for a model:

```
$availableStatuses = DataModdel::availableStatuses();
```

Provides the default status for a model (note that if a Model specific and non-model specific status has a default, the model specific will be default):

```
$defaultStatus = DataModdel::defaultStatus();
```

### The ability to sort by the Status Order

[](#the-ability-to-sort-by-the-status-order)

Default Order will be in ascending order:

```
$orderedStatuses = Status::order()->get();
```

Order by order field, ascending.

```
$orderedStatuses = Status::order('asc')->get();
```

Order by order field, descending.

```
$orderedStatuses = Status::order('desc')->get();
```

Order By a certain Model

```
    $orderedStatuses = Status::where('model', DataModel::class)->order()->get();
```

**OR**

```
    $orderedAscStatuses = DataModel::availableStatuses('asc');
    $orderedDescStatuses = DataModel::availableStatuses('desc');
```

### Getting Model Status Information

[](#getting-model-status-information)

Getting the model's current status

```
$model->status;
// Returns the status model object
```

Getting the model's status updates

```
$model->status_updates;
// Returns a Collection of status update model
```

Getting the model's latest status updates

```
$model->latestStatusUpdate();
// Returns the latest, in sequence, status update model object.
```

Future Feature Listing
----------------------

[](#future-feature-listing)

- Status Ordering
- Assigning Status to multiple Models
- UI Interface to provide CRUD functionality for Status Models

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Peter R Stanley](https://github.com/peterrstanley)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

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

Total

2

Last Release

1668d ago

PHP version history (2 changes)v1.0.0PHP ^7.4|^8.0

v1.1.0PHP ^7.3|^8.0

### Community

Maintainers

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

---

Top Contributors

[![peterrstanley](https://avatars.githubusercontent.com/u/1074200?v=4)](https://github.com/peterrstanley "peterrstanley (5 commits)")

---

Tags

composer-packagelaravellaravel-model-statuspackagephplaravellaravel-model-statusSnowPenguinStudios

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/snowpenguinstudios-laravel-model-status/health.svg)

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

###  Alternatives

[rtconner/laravel-likeable

Trait for Laravel Eloquent models to allow easy implementation of a 'like' or 'favorite' or 'remember' feature.

394388.0k5](/packages/rtconner-laravel-likeable)[highsolutions/eloquent-sequence

A Laravel package for easy creation and management sequence support for Eloquent models with elastic configuration.

121130.3k](/packages/highsolutions-eloquent-sequence)[cybercog/laravel-nova-ban

A Laravel Nova banning functionality for your application.

40199.8k](/packages/cybercog-laravel-nova-ban)[hpolthof/laravel-translations-db

A database translations implementation for Laravel 5.

545.8k](/packages/hpolthof-laravel-translations-db)[cubettech/lacassa

Cassandra based query builder for laravel.

358.5k](/packages/cubettech-lacassa)[phaza/single-table-inheritance

Single Table Inheritance Trait

1515.8k](/packages/phaza-single-table-inheritance)

PHPackages © 2026

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