PHPackages                             michaelnabil230/laravel-setting - 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. michaelnabil230/laravel-setting

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

michaelnabil230/laravel-setting
===============================

This package allows you to persists setting for Laravel projects.

v2.0.0(3y ago)36761[2 PRs](https://github.com/michaelnabil230/laravel-setting/pulls)MITPHPPHP ^8.1

Since Jan 7Pushed 2y ago1 watchersCompare

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

READMEChangelog (7)Dependencies (12)Versions (13)Used By (0)

This package allows you to persist in setting for Laravel projects and support laravel 10.
==========================================================================================

[](#this-package-allows-you-to-persist-in-setting-for-laravel-projects-and-support-laravel-10)

[![Latest Version on Packagist](https://camo.githubusercontent.com/51adfe03398267e3a85bebfce93a26f7865dbf44e717c741a3909cf4a3f539ba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d69636861656c6e6162696c3233302f6c61726176656c2d73657474696e672e737667)](https://packagist.org/packages/michaelnabil230/laravel-setting)[![Total Downloads](https://camo.githubusercontent.com/2706b9d7456c94830f72016a79d5f5a186133c7c21f8f04f26a3ae228a44d3a8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d69636861656c6e6162696c3233302f6c61726176656c2d73657474696e672e737667)](https://packagist.org/packages/michaelnabil230/laravel-setting)

[![Stars](https://camo.githubusercontent.com/969527d52f70813f422750e4bee02b9b84e0757da0121398b9cd287f909d5c74/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6d69636861656c6e6162696c3233302f6c61726176656c2d73657474696e67)](https://github.com/michaelnabil230/laravel-setting/stargazers)[![License](https://camo.githubusercontent.com/65a821968e9aa9861ce44693d3eef113b063dc1fb3ea560a34c759171d26d6c6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d69636861656c6e6162696c3233302f6c61726176656c2d73657474696e67)](https://github.com/michaelnabil230/laravel-setting/blob/main/LICENSE)[![Issues](https://camo.githubusercontent.com/9a0f6ea30f7d5e59dcf5bb796408e33175f8543a2243f6d8549af142c5d11dc5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6d69636861656c6e6162696c3233302f6c61726176656c2d73657474696e67)](https://github.com/michaelnabil230/laravel-setting/issues)

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

[](#installation)

You can install the package via composer:

```
composer require michaelnabil230/laravel-setting
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="setting-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="setting-config"
```

This is the contents of the published config file:

```
use MichaelNabil230\Setting\Models\Setting;

return [
    /*
    |--------------------------------------------------------------------------
    | Default Settings Store
    |--------------------------------------------------------------------------
    |
    | This option controls the default settings store that gets used while
    | using this settings library.
    |
    | Supported: "json", "database", "redis"
    |
    */

    'default' => 'json',

    /*
    |--------------------------------------------------------------------------
    | Drivers Stores
    |--------------------------------------------------------------------------
    |
    | The settings are stored.
    |
    */

    'drivers' => [
        'database' => [
            'driver' => \MichaelNabil230\Setting\Stores\DatabaseSettingStore::class,
            'options' => [
                'model' => Setting::class,
                'table' => 'settings', // name of table in dataBase
                'cache' => [
                    'enableCache' => false,
                    'cacheTtl' => 15, // TTL in seconds.
                ]
            ],
        ],

        'redis' => [
            'driver' => \MichaelNabil230\Setting\Stores\RedisSettingStore::class,
            'options' => [
                'connection' => 'default',
                'prefix' => 'setting',
            ],
        ],

        'json' => [
            'driver' => \MichaelNabil230\Setting\Stores\JsonSettingStore::class,
            'options' => [
                'path' => storage_path('settings.json'),
            ]
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Keys
    |--------------------------------------------------------------------------
    |
    | Your keys are used to insert settings data.
    |
    */

    'keys' => [
        //
    ],

    /*
    |--------------------------------------------------------------------------
    | Default Settings
    |--------------------------------------------------------------------------
    |
    | Default settings are used when a setting is not found in the store.
    |
    */

    'defaults' => [
        //
    ],
];
```

You can either access the setting store via its facade

```
