PHPackages                             fhusquinet/laravel-model-json-options - 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. fhusquinet/laravel-model-json-options

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

fhusquinet/laravel-model-json-options
=====================================

Store options as JSON values easily on your models.

3.0.0(3y ago)04.5k1[1 PRs](https://github.com/fhusquinet/laravel-model-json-options/pulls)MITPHPPHP ^8.0CI failing

Since Jul 6Pushed 3y ago1 watchersCompare

[ Source](https://github.com/fhusquinet/laravel-model-json-options)[ Packagist](https://packagist.org/packages/fhusquinet/laravel-model-json-options)[ Docs](https://github.com/fhusquinet/laravel-model-json-options)[ RSS](/packages/fhusquinet-laravel-model-json-options/feed)WikiDiscussions master Synced yesterday

READMEChangelog (6)Dependencies (5)Versions (8)Used By (0)

Easily store options on your Eloquent models using JSON and a simple API.
=========================================================================

[](#easily-store-options-on-your-eloquent-models-using-json-and-a-simple-api)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1fa4ac6ca1cd15f3b1fe650a57f7589b7b65fd2c8848e8d9a47ec7379b428dea/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666875737175696e65742f6c61726176656c2d6d6f64656c2d6a736f6e2d6f7074696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/fhusquinet/laravel-model-json-options)[![Total Downloads](https://camo.githubusercontent.com/0e2f212277e25180fa5fdad82abdda31c7a95b429ebe1e8996a1196b913478fd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f666875737175696e65742f6c61726176656c2d6d6f64656c2d6a736f6e2d6f7074696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/fhusquinet/laravel-model-json-options)

If you are storing a lot of values, especially booleans, as columns in your database, and if this data is not always the same for each row you might want to consider using a JSON column. To ease up the usage of it, this package provides an easy way API toscope results from your database and getting/setting options. If you are used to Laravel's syntax you will be familiar with this one as well.

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

[](#installation)

You can install the package via composer:

```
composer require fhusquinet/laravel-model-json-options
```

Usage
-----

[](#usage)

Add the HasOptions trait to your wanted models.

```
// App\Models\Article.php

namespace App\Models;

use FHusquinet\ModelOptions\Traits\HasOptions;
use Illuminate\Database\Eloquent\Model;

class Article extends Model
{
    use HasOptions;
```

You should also include the options column to the model's table using a migration.

```
Schema::table('articles', function (Blueprint $table) {
    $table->json('options')->nullable();
});
```

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

- [Florian Husquinet](https://github.com/fhusquinet)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity72

Established project with proven stability

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

Recently: every ~315 days

Total

6

Last Release

1454d ago

Major Versions

1.0.4 → 2.0.02021-01-19

2.0.0 → 3.0.02022-05-20

PHP version history (2 changes)1.0.0PHP ^7.0

3.0.0PHP ^8.0

### Community

Maintainers

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

---

Tags

fhusquinetlaravel-model-json-options

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fhusquinet-laravel-model-json-options/health.svg)

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

###  Alternatives

[cviebrock/eloquent-sluggable

Easy creation of slugs for your Eloquent models in Laravel

4.0k13.6M253](/packages/cviebrock-eloquent-sluggable)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[genealabs/laravel-pivot-events

This package introduces new eloquent events for sync(), attach(), detach() or updateExistingPivot() methods on BelongsToMany relation.

1404.9M8](/packages/genealabs-laravel-pivot-events)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)

PHPackages © 2026

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