2017 © Pedro Peláez
 

project setting

Persistent Laravel configuration settings.

image

larapacks/setting

Persistent Laravel configuration settings.

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 10 Versions
  • 8 % Grown

The README.md

Setting

Build Status Scrutinizer Code Quality Total Downloads Latest Stable Version License, (*1)

Description

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

Requirements

  • PHP >= 7.2
  • Laravel >= 6.0

Installation

Run the following command:, (*3)

composer require larapacks/setting

Note: The service provider and Setting facade are registered automatically., (*4)

Once that's complete, publish the migration and configuration file using:, (*5)

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

Then run php artisan migrate., (*6)

Usage

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

Setting a value:, (*8)

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

Setting multiple values:, (*9)

Setting::set([
    'key.1' => 'value',
    'key.2' => 'value',
    'key.3' => 'value',
]);

Retrieving a value:, (*10)

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

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

Retrieving a value or return default value if it doesn't exist:, (*11)

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

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

Retrieving the Setting model for a particular key:, (*12)

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

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

Retrieving all keys with values:, (*13)

Setting::set([
    'key.1' => 'value',
    'key.2' => 'value',
    'key.3' => 'value',
]);

$settings = Setting::all();

dd($settings);

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

Retrieving the your configured Setting model:, (*14)

$model = Setting::model();

$setting = new $model();

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

$setting->save();

Determining if a setting exists:, (*15)

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

Flipping a boolean setting:, (*16)

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

// Disable notifications.
Setting::flip('notifications');

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

// Enable notifications.
Setting::flip('notifications');

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

// Default flip setting:
Setting::flip('new-key');

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

Enabling a boolean setting:, (*17)

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

Setting::enable('notifications');

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

Disabling a boolean setting:, (*18)

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

Setting::disable('notifications');

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., (*19)

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

namespace App;

use Larapacks\Setting\Traits\SettingTrait;

class Setting extends Model
{
    use SettingTrait;
}

Encryption

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

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

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., (*23)

The Versions

06/09 2017

dev-master

9999999-dev

Persistent Laravel configuration settings.

  Sources   Download

MIT

The Requires

 

The Development Requires

settings configuration setting

06/09 2017

v1.0.8

1.0.8.0

Persistent Laravel configuration settings.

  Sources   Download

MIT

The Requires

 

The Development Requires

settings configuration setting

14/02 2017

v1.0.7

1.0.7.0

Persistent Laravel configuration settings.

  Sources   Download

MIT

The Requires

 

The Development Requires

settings configuration setting

08/02 2017

v1.0.6

1.0.6.0

Persistent Laravel configuration settings.

  Sources   Download

MIT

The Requires

 

The Development Requires

settings configuration setting

23/09 2016

v1.0.5

1.0.5.0

Persistent Laravel configuration settings.

  Sources   Download

MIT

The Requires

 

The Development Requires

settings configuration setting

24/07 2016

v1.0.4

1.0.4.0

Persistent Laravel configuration settings.

  Sources   Download

MIT

The Requires

 

The Development Requires

settings configuration setting

21/07 2016

v1.0.3

1.0.3.0

Persistent Laravel configuration settings.

  Sources   Download

MIT

The Requires

 

The Development Requires

settings configuration setting

18/07 2016

v1.0.2

1.0.2.0

Persistent Laravel configuration settings.

  Sources   Download

MIT

The Requires

 

The Development Requires

settings configuration setting

15/07 2016

v1.0.1

1.0.1.0

Persistent Laravel configuration settings.

  Sources   Download

MIT

The Requires

 

The Development Requires

settings configuration setting

15/07 2016

v1.0.0

1.0.0.0

Persistent Laravel configuration settings.

  Sources   Download

MIT

The Requires

 

The Development Requires

settings configuration setting