2017 © Pedro PelĂĄez
 

library setting-store

Laravel 5.5+ package to provide a simple model / facade for key/value storage.

image

leewillis77/setting-store

Laravel 5.5+ package to provide a simple model / facade for key/value storage.

  • Tuesday, February 20, 2018
  • by leewillis77
  • Repository
  • 1 Watchers
  • 2 Stars
  • 94 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 3 Versions
  • 15 % Grown

The README.md

Setting Store

Laravel 5.5+ package to provide a simple model / facade for key/value storage., (*1)

Treeware

If you use this package in production, we ask that you buy the world some trees to thank us for our work. By contributing to our forest you’ll be creating employment for local families and restoring wildlife habitats., (*2)

We offset our carbon footprint via Ecologi , (*3)

Installation

Add the package to your Laravel project using composer:, (*4)

$ composer require leewillis77/setting-store

Configuration

Publish the database migration using the following artisan command:, (*5)

$ php artisan vendor:publish --provider="Leewillis77\SettingStore\Providers\ServiceProvider" --tag="migrations"  

Run the migration to create the storage table., (*6)

$ php artisan migrate

Usage

Store a (string) setting value

// Set a value for the key 'foo'
SettingStore::set('foo', 'bar');

Store a (non-string) setting value

// Set a value for the key 'foo'. The value will be serialized before storing.
SettingStore::setSerialized('foo', ['bar']);

Retrieve a (string) setting value

// Retrieve a value for the key 'foo'
$value = SettingStore::get('foo');

Retrieve a (string) setting, with a fallback value

// Retrieve a value for the key 'foo', or value 'foobar' if not found
$value = SettingStore::get('foo', 'foobar');

Retrieve a (non-string) setting value

// Retrieve a value for the key 'foo'. The value will be unserialized before being returned.
SettingStore::getSerialized('foo');

Retrieve a (non-string) setting value, with a fallback

// Retrieve a value for the key 'foo'
SettingStore::getSerialized('foo', ['bar']);

Accessing the SettingStore

You can access the SettingStore using the SettingStore facade, e.g., (*7)

$value = SettingStore::get('foo');

Alternatively, you can inject the repository into your controllers, e.g., (*8)

<?php

use Leewillis77\SettingStore\Repositories\SettingStoreRepository;

public function myControllerAction(SettingStoreRepository $settingStore)
{
    $value = $settingStore->get('foo');
}

You can also retrieve the repository from the service container., (*9)

<?php

$settingStore = App::make('setting_store');
$value = $settingStore->get('foo');

Treeware

You're free to use this package, but if it makes it to your production environment you are required to buy the world a tree., (*10)

It’s now common knowledge that one of the best tools to tackle the climate crisis and keep our temperatures from rising above 1.5C is to plant trees. If you support this package and contribute to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats., (*11)

You can buy trees here offset.earth/ademtisoftware, (*12)

Read more about Treeware at treeware.earth, (*13)

The Versions

20/02 2018

dev-master

9999999-dev https://github.com/leewillis77/setting-store

Laravel 5.5+ package to provide a simple model / facade for key/value storage.

  Sources   Download

GPL-3.0-or-later

The Requires

 

The Development Requires

laravel settings

20/02 2018

2.0.0

2.0.0.0 https://github.com/leewillis77/setting-store

Laravel 5.5+ package to provide a simple model / facade for key/value storage.

  Sources   Download

GPL-3.0-or-later

The Requires

 

The Development Requires

laravel settings

19/02 2018

1.0.0

1.0.0.0 https://github.com/leewillis77/setting-store

Laravel 5.5+ package to provide a simple model / facade for key/value storage.

  Sources   Download

GPL-3.0-or-later

The Requires

 

The Development Requires

laravel settings