2017 © Pedro Peláez
 

library eloquent-settings

An Eloquent Settings Repository

image

vluzrmos/eloquent-settings

An Eloquent Settings Repository

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

The README.md

Eloquent Settings Repository

A package to store settings of your application on database., (*1)

Installation

composer require vluzrmos/eloquent-settings

Configuration

First, you have to publish the configs and migrations:, (*2)

php artisan vendor:publish --provider=Vluzrmos\EloquentSettings\Providers\EloquentSettingsServiceProvider

Second, run the migrations:, (*3)

php artisan migrate

Usage

You can use the dependency injection or the setting helper:, (*4)

use \Vluzrmos\EloquentSettings\Setting;

class YourInjectableClass {

   protected $settings;

   public function __construct (Setting $settings) {
       $this->settings = $settings;   
   }

   public function theMethod() {
       $option = $this->settings->get('my.awesome.option', 'default-value');
   }
} 

It's more easy to use the setting helper:, (*5)

// Getter
$option = setting('my.awesome.option', 'default-value');
//or
$option = setting()->get('my.awesome.option', 'default-value');

// Setter
setting()->set('my.awesome.option', 'That is Awesome!');

setting()->save(); //remember, without this the settings will not be stored on database

Setting API

get(string key, mixed default=null) : mixed - Get a setting on database, if doens't exists it will use the default value., (*6)

set(string|array key, mixed value=null) : void - Set a value or array of key=>values to the settings., (*7)

forget(string key) : void - Clear an value of the settings., (*8)

has(string key) : bool - Check if settings has a given key., (*9)

all() : array - Get an array of all settings., (*10)

except(string|array keys ...) : array - Get settings which doesn't match with that given keys., (*11)

only(string|array keys ...) : array - Get settings which match with that given keys., (*12)

save() : void - IMPORTANT! Store settings on the database., (*13)

update(string|array keys, mixed value=null) : void - Sets and saves one or more settings., (*14)

The Versions

20/02 2018

dev-master

9999999-dev

An Eloquent Settings Repository

  Sources   Download

MIT

The Requires

 

laravel settings eloquent

20/02 2018

v0.0.2

0.0.2.0

An Eloquent Settings Repository

  Sources   Download

MIT

The Requires

 

laravel settings eloquent

29/12 2015

v0.0.1

0.0.1.0

An Eloquent Settings Repository

  Sources   Download

MIT

The Requires