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

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

a1383n/laravel-eloquent-settings
================================

Easily manage model-specific settings in Laravel with Laravel Eloquent Settings—a versatile package for streamlined configuration.

v0.2.0(1y ago)1209[2 PRs](https://github.com/a1383n/laravel-eloquent-settings/pulls)MITPHPPHP ^8.1CI passing

Since Oct 13Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/a1383n/laravel-eloquent-settings)[ Packagist](https://packagist.org/packages/a1383n/laravel-eloquent-settings)[ Docs](https://github.com/a1383n/laravel-eloquent-settings)[ RSS](/packages/a1383n-laravel-eloquent-settings/feed)WikiDiscussions 0.x Synced 1mo ago

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

Laravel Eloquent Settings
=========================

[](#laravel-eloquent-settings)

Laravel Eloquent Settings is a powerful package for managing model-specific settings in Laravel applications. This package provides a flexible and efficient way to define, handle, and persist settings for your Eloquent models.

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

[](#installation)

You can install the package via composer:

```
composer require a1383n/laravel-eloquent-settings
```

Next, publish the configuration file:

```
php artisan vendor:publish --provider=LaravelEloquentSettings\EloquentSettingsServiceProvider
```

This will create a configuration file at `config/eloquent_settings.php` and a migration at `database/migeration/**_create_eloquent_settings_table.php`

Run the migrations to create the necessary database table:

```
php artisan migrate
```

Usage
-----

[](#usage)

### Implement HasSettingsInterface on your Model

[](#implement-hassettingsinterface-on-your-model)

First, make sure your model implements the `HasSettingsInterface` and uses the `HasSettings` trait. Implement the `definedSettings` method to define the settings for your model:

```
use Illuminate\Database\Eloquent\Model;
use LaravelEloquentSettings\Enums\SettingValueType;
use LaravelEloquentSettings\Contracts\HasSettingsInterface;
use LaravelEloquentSettings\HasSettings;

class User extends Model implements HasSettingsInterface
{
    use HasSettings;

    public function definedSettings(SettingDefinition $definition): void
    {
        $definition->define('locale')
            ->type(SettingValueType::STRING)
            ->default('fa-IR');

        $definition->define('extra')
            ->type(SettingValueType::ARRAY)
            ->nullable();
    }
}
```

### Use Settings

[](#use-settings)

Now that you've defined settings, you can interact with them through the `SettingHandler`:

```
use App\Models\User;

$user = User::findOrFail(1);
$user->getSettingValueByName('locale');
$user->setSettingValueByName('locale', 'en-US');
```

### SettingResolver and SettingSetter

[](#settingresolver-and-settingsetter)

The package also provides `SettingResolver` and `SettingSetter` for handling setting resolution and updates:

```
use LaravelEloquentSettings\EloquentSettings;
use LaravelEloquentSettings\SettingResolver;
use LaravelEloquentSettings\SettingSetter;
use App\Models\User;

$handler = EloquentSettings::getHandler(User::find(1));

$resolver = new SettingResolver($handler);
$value = $resolver($settings->get('locale'));

$setter = new SettingSetter($handler);
$setter('extra', ['foo' => 'bar']);
```

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

[](#configuration)

You can customize the package behavior by modifying the `eloquent_settings.php` configuration file. Adjust settings such as the database table name and default values according to your requirements.

Credits
-------

[](#credits)

This package is inspired by the need for a simple and effective way to manage model-specific settings in Laravel applications.

License
-------

[](#license)

Laravel Eloquent Settings is open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance55

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 77.8% 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 ~122 days

Total

3

Last Release

697d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8164ad8dda860ea2bbdb593ccdd3182b2f0f4825275a676a3ca6d8db596b148b?d=identicon)[amirsobhan](/maintainers/amirsobhan)

---

Top Contributors

[![a1383n](https://avatars.githubusercontent.com/u/25206082?v=4)](https://github.com/a1383n "a1383n (7 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

---

Tags

eloquentlaravelmodel-settings

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[overtrue/laravel-versionable

Make Laravel model versionable.

585308.0k5](/packages/overtrue-laravel-versionable)[abbasudo/laravel-purity

elegant way to add filter and sort in laravel

514330.5k1](/packages/abbasudo-laravel-purity)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135192.6k5](/packages/statamic-rad-pack-runway)[dragon-code/laravel-deploy-operations

Performing any actions during the deployment process

240173.5k2](/packages/dragon-code-laravel-deploy-operations)[stayallive/laravel-eloquent-observable

Register Eloquent model event listeners just-in-time directly from the model.

2928.9k7](/packages/stayallive-laravel-eloquent-observable)

PHPackages © 2026

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