Persistent Laravel configuration settings.

Installs: 5 638

Dependents: 1

Suggesters: 0

Security: 0

Stars: 5

Watchers: 3

Forks: 2

Open Issues: 0


v3.0.2 2023-03-07 20:17 UTC

This package is auto-updated.

Last update: 2024-06-07 23:05:32 UTC


Build Status Scrutinizer Code Quality Total Downloads Latest Stable Version License


Setting is an easy, encrypted & cached, database key => value store for your laravel application.


  • PHP >= 7.2
  • Laravel >= 6.0


Run the following command:

composer require larapacks/setting

Note: The service provider and Setting facade are registered automatically.

Once that's complete, publish the migration and configuration file using:

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

Then run php artisan migrate.


Note: All usage below can be accessed via the helper method setting().

Setting a value:

Setting::set('key', 'value');

Setting multiple values:

    'key.1' => 'value',
    'key.2' => 'value',
    'key.3' => 'value',

Retrieving a value:

$value = Setting::get('key.1');

dd($value); // Returns 'value'

Retrieving a value or return default value if it doesn't exist:

$value = Setting::get('non-existent-key', 'default');

dd($value); // Returns 'default'

Retrieving the Setting model for a particular key:

$model = Setting::find('key.1');

dd($model); // Reurns instance of Model (your configured model).

Retrieving all keys with values:

    'key.1' => 'value',
    'key.2' => 'value',
    'key.3' => 'value',

$settings = Setting::all();


// Returns:
// array [
//  'key.1' => 'value',
//  'key.2' => 'value',
//  'key.3' => 'value',
// ]

Retrieving the your configured Setting model:

$model = Setting::model();

$setting = new $model();

$setting->key = 'key';
$setting->value = 'value';


Determining if a setting exists:

if (Setting::has('key')) {
    // The setting exists.

Flipping a boolean setting:

Setting::set('notifications', true);

// Disable notifications.

dd(Setting::get('notifications')); // Returns false.

// Enable notifications.

dd(Setting::get('notifications')); // Returns true.

// Default flip setting:

dd(Setting::get('new-key')); // Retuns true.

Enabling a boolean setting:

Setting::set('notifications', false);


dd(Setting::get('notifications')); // Returns true.

Disabling a boolean setting:

Setting::set('notifications', true);


dd(Setting::get('notifications')); // Returns false.

Using your own model

To use your own model, change the model configuration option in your config/settings.php file.

When you create your own model, be sure to include the trait: Larapacks\Setting\Traits\SettingTrait:

namespace App;

use Larapacks\Setting\Traits\SettingTrait;

class Setting extends Model
    use SettingTrait;


Encryption can be enabled or disabled in the published configuration file. By default, it is enabled.

Encryption is performed by laravel's included helper methods encrypt() and decrypt().

You can enable or disable encryption at any time, however upon disabling encryption you will receive the raw encrypted string for settings that have previously been encrypted.