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

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

stechstudio/laravel-settings
============================

Polymorphic, typed key/value settings for any Eloquent model.

v1.0.0(today)00MITPHPPHP ^8.2

Since Jun 27Pushed todayCompare

[ Source](https://github.com/stechstudio/laravel-settings)[ Packagist](https://packagist.org/packages/stechstudio/laravel-settings)[ Docs](https://github.com/stechstudio/laravel-settings)[ RSS](/packages/stechstudio-laravel-settings/feed)WikiDiscussions main Synced today

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

Laravel Settings
================

[](#laravel-settings)

Polymorphic, typed key/value settings for any Eloquent model.

Drop the `HasSettings` trait onto any model and instantly get a bag of settings stored in a single polymorphic table. Values keep their PHP type — booleans come back as booleans, arrays as arrays, integers as integers — without you having to think about casting.

```
$user->setSetting('theme', 'dark');
$user->setSetting('notifications', true);
$user->setSetting('limits', ['daily' => 100, 'monthly' => 2000]);

$user->setting('theme');          // "dark"
$user->setting('notifications');  // true  (bool)
$user->setting('limits');         // ['daily' => 100, 'monthly' => 2000]
$user->setting('missing', 'n/a'); // "n/a" (default)
```

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

[](#installation)

```
composer require stechstudio/laravel-settings
```

Publish and run the migration:

```
php artisan vendor:publish --tag=settings-migrations
php artisan migrate
```

The package auto-registers its service provider. The migration is also loaded automatically, so in development you can migrate without publishing — publish it when you want the file committed to your app.

Optionally publish the config:

```
php artisan vendor:publish --tag=settings-config
```

Usage
-----

[](#usage)

Add the trait to any model:

```
use STS\Settings\Concerns\HasSettings;

class User extends Authenticatable
{
    use HasSettings;
}
```

### Reading &amp; writing

[](#reading--writing)

```
// Write — the cast type is auto-detected from the value
$user->setSetting('theme', 'dark');

// Read, with an optional default
$user->setting('theme');             // "dark"
$user->setting('missing', 'default'); // "default"

// Existence
$user->hasSetting('theme');          // true

// Delete
$user->deleteSetting('theme');       // true

// Everything as a name => value map
$user->allSettings();                // ['theme' => 'dark', ...]

// Increment a numeric setting (creates it at $amount if absent)
$user->incrementSetting('login_count');     // +1
$user->incrementSetting('credits', 25);     // +25
```

### Type casting

[](#type-casting)

Types are detected automatically on write (`bool`, `int`, `float`, `array`, `string`). Pass an explicit cast as the third argument when you need to override detection — for example to store a numeric string as a string:

```
use STS\Settings\Models\Setting;

$user->setSetting('zip', '90210', Setting::CAST_STRING);
$user->setting('zip'); // "90210" (stays a string)
```

Available casts: `Setting::CAST_STRING`, `CAST_INT`, `CAST_FLOAT`, `CAST_BOOL`, `CAST_ARRAY`, `CAST_JSON`.

### The relationship

[](#the-relationship)

`HasSettings` adds a standard `settings()` morph-many relationship, so you can eager load and query it like any other:

```
$users = User::with('settings')->get();
```

Settings are scoped to their owner — each model only ever sees its own.

Configuration
-------------

[](#configuration)

`config/settings.php`:

```
return [
    // The table that holds settings rows.
    'table' => 'settings',

    // The model representing a single setting. Point this at your own
    // subclass of STS\Settings\Models\Setting to add scopes or behaviour.
    'model' => STS\Settings\Models\Setting::class,
];
```

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

MIT. See [LICENSE.md](LICENSE.md).

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

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

Unknown

Total

1

Last Release

0d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/315be5f111b5501a41b99a0205c9c85915335391168a0ed10316546a1a38bbd8?d=identicon)[jszobody](/maintainers/jszobody)

---

Top Contributors

[![jszobody](https://avatars.githubusercontent.com/u/203749?v=4)](https://github.com/jszobody "jszobody (1 commits)")

---

Tags

laravelSettingseloquentpreferencespolymorphic

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

### Embed Badge

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

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

###  Alternatives

[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k29.9M42](/packages/kirschbaum-development-eloquent-power-joins)[spatie/laravel-sluggable

Generate slugs when saving Eloquent models

1.5k12.4M294](/packages/spatie-laravel-sluggable)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[watson/validating

Eloquent model validating trait.

9733.4M53](/packages/watson-validating)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8723.1M23](/packages/yajra-laravel-oci8)[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k322.4k1](/packages/cybercog-laravel-love)

PHPackages © 2026

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