2017 © Pedro Peláez
 

library laravel-settings

image

ionutmilica/laravel-settings

  • Friday, June 9, 2017
  • by ionutmilica
  • Repository
  • 4 Watchers
  • 1 Stars
  • 730 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 20 Versions
  • 12 % Grown

The README.md

Laravel Settings

Build Status, (*1)

Laravel settings it's a composer package made for our projects that allows developers to persist settings into database or json files., (*2)

Installation

PHP 5.4+ and Laravel 5.* are required., (*3)

To get the latest version of Laravel Settings run the following command:, (*4)

composer require ionutmilica/laravel-settings

Once Laravel Settings is installed, you need to register the service provider. Open up config/app.php and add the following to the providers key., (*5)

  • 'IonutMilica\LaravelSettings\SettingsServiceProvider'

You can register the Settings facade in the aliases key of your config/app.php file if you like., (*6)

  • 'Settings' => 'IonutMilica\LaravelSettings\Facade'

If you want to have persistent settings, you will need to add a new middleware in app/Http/Kernel.php to the middleware key., (*7)

  • 'IonutMilica\LaravelSettings\SavableMiddleware',

Laravel settings default driver is set to json. If you want to change it you can execute artisan vendor:publish command and then modify app/config/settings.php file., (*8)

If you chose database driver you should also migrate the database with php artisan migrate., (*9)

How to use it

For simple usage we provide a helper that provides all the features you need:, (*10)

  • Fetching a value
$canRegister = settings('restrictions.register');

if (! $canRegister) {
    // do something
}

// Fetching with default value

$canRegister = settings('restrictions.register', false);

// Fetching and save the setting if it does not exist

$canRegister = settings('restrictions.register, false, true);

  • Storing a new setting or editing an old one?
settings()->set('my-setting', 'some-value');
  • Checking for a setting existence
if (settings()->has('my-setting')) {
    // do something
}
  • Wanting to delete a not needed setting?
settings()->forgot('my-setting');
  • Force the saving of the settings into the datastore
settings()->set('the-answer', 42);
settings()->save();

You can also inject the settings instance into your laravel controller:, (*11)


use IonutMilica\LaravelSettings\SettingsContract; class RegistrationController extends Controller { public function register(Request $request, SettingsContract $settings) { if ($settings->get('restrictions.registration')) { return redirect()->back(); } // Do something } }

More examples will follow!, (*12)

The Versions

09/06 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

by Milica Ionut

09/06 2017

2.0.1

2.0.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Milica Ionut

21/09 2016

dev-laravel5.1

dev-laravel5.1

  Sources   Download

MIT

The Requires

 

The Development Requires

by Milica Ionut

21/09 2016

dev-laravel5.2

dev-laravel5.2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Milica Ionut

21/09 2016

2.0.0

2.0.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Milica Ionut

16/09 2016

dev-laravel5.0

dev-laravel5.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Milica Ionut

16/09 2016

1.0.2

1.0.2.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Milica Ionut

24/01 2016

1.0.1

1.0.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Milica Ionut

23/01 2016

1.0.0

1.0.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Milica Ionut

15/12 2015

0.5.1

0.5.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Milica Ionut

15/12 2015

0.5.0

0.5.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Milica Ionut

13/09 2015

0.4.2

0.4.2.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Milica Ionut

31/08 2015

0.4.1

0.4.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Milica Ionut

27/08 2015

0.4.0

0.4.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Milica Ionut

18/08 2015

0.3.3

0.3.3.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Milica Ionut

17/08 2015

0.3.2

0.3.2.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Milica Ionut

17/08 2015

0.3.1

0.3.1.0

  Sources   Download

The Requires

 

The Development Requires

by Milica Ionut

17/08 2015

0.3.0

0.3.0.0

  Sources   Download

The Requires

 

The Development Requires

by Milica Ionut

17/08 2015

0.2.0

0.2.0.0

  Sources   Download

The Requires

 

The Development Requires

by Milica Ionut

14/08 2015

0.1.0

0.1.0.0

  Sources   Download

The Requires

 

The Development Requires

by Milica Ionut