PHPackages                             rolfhaug/laravel-model-settings - 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. rolfhaug/laravel-model-settings

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

rolfhaug/laravel-model-settings
===============================

A package that gives you a fluent api to add key/value settings to any Eloquent model

v0.0.2(7y ago)52.5k2[1 PRs](https://github.com/rahaug/laravel-model-settings/pulls)mitPHP

Since Aug 9Pushed 7y ago1 watchersCompare

[ Source](https://github.com/rahaug/laravel-model-settings)[ Packagist](https://packagist.org/packages/rolfhaug/laravel-model-settings)[ RSS](/packages/rolfhaug-laravel-model-settings/feed)WikiDiscussions master Synced yesterday

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

Laravel Model Settings
======================

[](#laravel-model-settings)

This package allows you to easily extend any Laravel Model, with a Settings Model. Perfect for configuration settings and personal preferences.

You can then easily set and retrieve key/value pairs through an elegant API. If the setting does not exist, `NULL` will be returned.

```
$user = User::find(1);

$user->settings->set('my_setting', 'my_value');

echo $user->settings->my_setting; // my_value

```

---

Installation
============

[](#installation)

`composer require rolfhaug/laravel-model-settings`

If you're using an older version than **Laravel 5.6**, add this to your providers in `config/app.php`.

`RolfHaug\ModelSettings\ModelSettingsProvider::class,`

Create a new Settings model
---------------------------

[](#create-a-new-settings-model)

1. Use the command to create a new settings model

`art make:model-settings --model=user`

2. Add the Settings trait to your model

`use RolfHaug\ModelSettings\Settings;`

> Tip: The command creates a migration that can be rolled back.

---

How to use the package
======================

[](#how-to-use-the-package)

```
$user = User:find(1);

```

Set settings
------------

[](#set-settings)

```
// Single setting
$user->settings->set('newsletter', true);

// Array of settings
$settings = [
	['awesome_setting' => 'awesome_value'],
	['another_setting' => 'another_value']
];

$user->settings->set($settings);

```

Access settings
---------------

[](#access-settings)

If the setting does not exist, `NULL` will be returned.

```
$user->settings->newsletter;

// Array of all available settings
$user->settings->all();

```

Destroy setting
---------------

[](#destroy-setting)

```
$user->settings->delete('newsletter');

```

Scopes
------

[](#scopes)

```
$users = User::whereSetting('newsletter', true)->get();

$users = User::whereHasSetting('newsletter')->get();

$users = User::whereDoesntHaveSetting('newsletter')->get();

```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.2% 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 ~25 days

Total

2

Last Release

2808d ago

### Community

Maintainers

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

---

Top Contributors

[![rahaug](https://avatars.githubusercontent.com/u/306927?v=4)](https://github.com/rahaug "rahaug (15 commits)")[![hootlex](https://avatars.githubusercontent.com/u/6147968?v=4)](https://github.com/hootlex "hootlex (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rolfhaug-laravel-model-settings/health.svg)

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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