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

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

moirei/settings
===============

A simple solution for application settings.

1.3.0(1mo ago)0506MITPHPPHP ^8.2

Since Nov 12Pushed 1mo agoCompare

[ Source](https://github.com/moirei/laravel-settings)[ Packagist](https://packagist.org/packages/moirei/settings)[ RSS](/packages/moirei-settings/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (18)Versions (5)Used By (0)

Simplified application settings
===============================

[](#simplified-application-settings)

This package is a simple approach to managing Eloquent model settings.

This package currently does not support managing global app settings.

```
$notificationsEnabled = $user->settings->get('notifications.enable');
```

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

[](#installation)

```
composer require moirei/settings
```

Publish the config

```
php artisan vendor:publish --tag="model-settings"
```

Usage
-----

[](#usage)

### Cast attributes

[](#cast-attributes)

The simplest way to use the with a model is casting to the settings collection.

```
use MOIREI\Settings\AsSettingsCollection;
use MOIREI\Fields\Inputs\Boolean;
...
class User extends Model{
    ...
    protected $casts = [
        'settings' => AsSettingsCollection::class,
    ];

    /**
     * Get settings configuration (optional)
     *
     * @return array
     */
    public function settingsConfig(): array
    {
        return [
            'notifications.enable' => Boolean::make('Enable notification')->default(false),
        ];
    }
}
```

New user models with empty settings should have defauls.

```
$user = new User();
$notificationsEnabled = $user->settings->get('notifications.enable');

// Or provide a prefered default
$notificationsEnabled = $user->settings->get('notifications.enable', true);
```

Directly access settings values

```
$notifications = $this->model->settings->notifications;

expect($notifications)->toBeArray();
```

### Has settings trait

[](#has-settings-trait)

For a more function approach to accessing settings, ascribe the `HasSettings` trait to your model.

This trait also provides a default `settingsConfig` method that resolves defaults from `settings.php` config. E.g. the `User` model will expect defaults in `defaults.users` of your config.

```
use MOIREI\Settings\HasSettings;
...
class User extends Model{
    use HasSettings;
    ...
}
```

```
$user = new User();
expect($user->settings())->toBeCollection();
expect($user->settings('notifications.enable'))->toBeBool();
```

Reusable settings
-----------------

[](#reusable-settings)

You can reusable settings

```
class UserSettings extends Settings
{
    /**
     * @inheritdoc
     */
    public function fields(): array
    {
        return [
            'notifications.enable' => Boolean::make('Enable notification')->default(false)
        ];
    }
}
```

Update in config

```
// config/settings.php
'groups' => [
   'users' => \App\Settings\UserSettings::class,
],
```

Now your model can be pointed to the config.

```
class User extends Model{
    use HasSettings;

    // optional if lower-cased pluralised form of class name matches name in groups
    protected $settingsConfig = 'users';
}
```

Tests
-----

[](#tests)

```
composer test
```

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance89

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity65

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

Total

4

Last Release

58d ago

PHP version history (2 changes)1.0.0PHP ^8.0

1.3.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/7ac6a15a7b2f9055a98e4419e0d2820f72db3567706837ec388baee535d3e3e7?d=identicon)[moirei](/maintainers/moirei)

---

Top Contributors

[![augustusnaz](https://avatars.githubusercontent.com/u/51074349?v=4)](https://github.com/augustusnaz "augustusnaz (3 commits)")

---

Tags

laravelSettingsuser settingsmodel settingsmoirei

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/moirei-settings/health.svg)

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

###  Alternatives

[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[bensampo/laravel-embed

Painless responsive embeds for videos, slideshows and more.

142146.8k](/packages/bensampo-laravel-embed)[zachleigh/laravel-property-bag

Easy Laravel user settings using a property bag

85340.3k](/packages/zachleigh-laravel-property-bag)[dragon-code/pretty-routes

Pretty Routes for Laravel

10058.7k4](/packages/dragon-code-pretty-routes)[laracraft-tech/laravel-useful-additions

A collection of useful Laravel additions!

58109.4k](/packages/laracraft-tech-laravel-useful-additions)[watson/nameable

Format names of users into full, familiar and abbreviated forms

299.7k](/packages/watson-nameable)

PHPackages © 2026

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