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

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

walidos/laravel-settings
========================

App &amp; Models Settings for Laravel

2.2(1y ago)09MITPHPPHP ^8.1

Since Dec 8Pushed 1y ago1 watchersCompare

[ Source](https://github.com/walidos04/laravel-settings)[ Packagist](https://packagist.org/packages/walidos/laravel-settings)[ Docs](https://github.com/walidos/laravel-settings)[ RSS](/packages/walidos-laravel-settings/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (4)Used By (0)

App &amp; Models Settings for Laravel
=====================================

[](#app--models-settings-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9095cfc1fc6a1815660f7ee92e94277585564563451bf6b92cdfa0bd3db2439c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736d6172746973616e2f6c61726176656c2d73657474696e67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/smartisan/laravel-settings)[![GitHub Tests Action Status](https://github.com/itsmohd/laravel-settings/workflows/run-tests/badge.svg)](https://github.com/itsmohd/laravel-settings/actions?query=workflow%3Arun-tests)[![Total Downloads](https://camo.githubusercontent.com/b87b01625636c7cc8e22dffca2a12a5df2a326d2d5da195f58caed8b5b03c96d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736d6172746973616e2f6c61726176656c2d73657474696e67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/smartisan/laravel-settings)

This package allows you to store application wide and model specific Laravel settings. Settings values are type-cast and stored properly. You can also define your own casts and store repository.

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

[](#installation)

Install the package via composer:

```
composer require smartisan/laravel-settings
```

Publish the config file with:

```
php artisan vendor:publish --provider="Smartisan\Settings\SettingsServiceProvider" --tag="config"
```

Publish the migration file with:

```
php artisan vendor:publish --provider="Smartisan\Settings\SettingsServiceProvider" --tag="migrations"
```

And finally run the migration with:

```
php artisan migrate
```

Usage
-----

[](#usage)

The package provides various APIs to access the settings manager. You can access it with Settings facade, settings() helper method and via HasSettings trait on your models.

### Store Settings

[](#store-settings)

You can set single entry, or multiple entries of settings. The values of objects will be cast according to the rules defined in settings.php config file.

- One Entry

```
Settings::set('key', 'value');
```

- Multiple Entries

You can set multiple settings entries by passing an associative array of keys and values. Casts will be applied on all the payload, even on nested arrays.

```
Settings::set([
    'k1' => Carbon::now(),
    'k2' => [
        'k3' => $user,
        'k4' => [
            'k5' => $model
        ],
    ]
]);
```

- Specify Settings Group

It's possible to categorize your settings into groups by calling group method.

```
Settings::group('name')->set('key', 'value');

Settings::group('name')->set([
    'k1' => 'v1',
    'k2' => 'v2',
]);
```

- Model Specific Settings

It's also possible to set settings for a specific model by calling for method

```
Settings::for($model)->set('key', 'value');

Settings::for($model)->set([
    'k1' => 'v1',
    'k2' => 'v2',
]);
```

- Mixing Filters

You can mix all filters together like this:

```
Settings::for($model)->group('name')->set('key', 'value');
```

### Retrieve Settings

[](#retrieve-settings)

You can retrieve one or multiple entries and specify the default value if not exist.

- One Entry

```
Settings::get('k1', 'default');
```

- Multiple Entries

If the entry key does not exist, the default value will be placed instead

```
Settings::get(['k1', 'k2', 'k3'], 'default');
```

- All Entries

If you want to retrieve all entries, you simply call all method. You can also specify the model or group. Also to excempt some specific keys.

**Note:** Remember that retrieving all entries without specifying the group or model, will retrieve all entries that has no group or model set. You can consider these as (global app settings).

```
Settings::all();

Settings::for($model)->all();

Settings::for($model)->group('name')->all();

Settings::except('k1', 'k2')->for($model)->group('name')->all();

Settings::except('k1')->for($model)->group('name')->all();
```

### Forget Entry

[](#forget-entry)

You can remove entries by calling forget method.

```
Settings::forget('key');

Settings::for($model)->group('name')->forget('key');
```

### Determine Existance

[](#determine-existance)

You can determine whether the given settings entry key exists or not

```
Settings::exist('key');

Settings::for($model)->exist('key');

Settings::for($model)->group('name')->exist('key');
```

### Helper Method

[](#helper-method)

The package also ships with a settings helper method, you can use it instead of using Settings Facade

```
settings()->set('key', 'value');
...
```

### HasSettings Trait

[](#hassettings-trait)

You can use HasSettings trait on your Eloquent models as well

1. First prepare your model

```
use Smartisan\Settings\HasSettings;

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

2. Now you can call settings() method on that model. This is equivelant to `Settings::for($model)`

```
$user->settings()->set('k1', 'v1');
...
```

Custom Repositories
-------------------

[](#custom-repositories)

If you don't want to use the database repository, you can easily create your own settings repository. To do that

1. Create a class of your repository that implements Repository interface and implement the following methods

```
use Smartisan\Settings\Contracts\Repository;

class FileRepository implements Repository
{
    public function get($key,$default = null) {
        //
    }

    public function set($key,$value = null) {
        //
    }

    public function forget($key) {
        //
    }

    public function all() {
        //
    }
}
```

2. In settings configuration file, add your own repository config to repositories attribute

```
    'repositories' => [
        ...

        'file' => [
            ...
        ]
    ],
```

3. Change the default repository in settings config file to your own repository implementation

Custom Casts
------------

[](#custom-casts)

The package allows you to easily create your own casting rules of any object type.

1. Create your own cast class that implements Castable interface.

**Note:** The set method is called when the value of the entries is being stored to the repository, and the get method is called when the value is being retrieved from the repository.

```
use Smartisan\Settings\Contracts\Castable;

class CustomCast implements Castable
{
    public function set($payload) {
        //
    }

    public function get($payload) {
        //
    }
}
```

2. Add the casts to the array of casts in settings config file

```
'casts' => [
    ...
    CustomDataType::class => CustomCast::class
]
```

**Note:** If you want to pass a parameter to your cast, you can set an object of the cast instead of cast class name

```
'casts' => [
    ...
    CustomDataType::class => new CustomCast('param')
]
```

Settings Cache
--------------

[](#settings-cache)

You can easily enable or disable caching settings in settings.php config file. You can also specify which caching store to use

```
'cache' => [
    'enabled' => env('SETTINGS_CACHE_ENABLED', false),
    'store' => null,
    'prefix' => null,
],
```

Testing
-------

[](#testing)

To run the package's tests, simply call the following command

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

- [Mohammed Isa](https://github.com/iamohd)
- [All Contributors](../../contributors)

Alternatives
------------

[](#alternatives)

- [spatie/laravel-settings](https://github.com/spatie/laravel-settings)
- [akaunting/laravel-setting](https://github.com/akaunting/laravel-setting)

License
-------

[](#license)

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

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.5% 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 ~225 days

Total

2

Last Release

657d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/42adc2a89289da4a648e1dee7f5f8aaeb4bcbd620c88fb34e4bfc34e9eedc403?d=identicon)[walidos04](/maintainers/walidos04)

---

Top Contributors

[![iamohdisa](https://avatars.githubusercontent.com/u/104384295?v=4)](https://github.com/iamohdisa "iamohdisa (5 commits)")[![walidos04](https://avatars.githubusercontent.com/u/70044166?v=4)](https://github.com/walidos04 "walidos04 (2 commits)")[![ValenokPC](https://avatars.githubusercontent.com/u/16735162?v=4)](https://github.com/ValenokPC "ValenokPC (1 commits)")

---

Tags

laravel-settings

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M683](/packages/barryvdh-laravel-ide-helper)[spatie/laravel-settings

Store your application settings

1.5k5.9M72](/packages/spatie-laravel-settings)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M157](/packages/orchestra-canvas)[kirschbaum-development/commentions

A package to allow you to create comments, tag users and more

12369.2k](/packages/kirschbaum-development-commentions)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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