Skip to content

byancode/settings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Settings

This package allows you to save the configuration in a more persistent way. Use the database to save your settings, you can save values in json format. You can also override the Laravel configuration.

Getting Started

1. Install

Run the following command:

composer require byancode/settings

2. Register (for Laravel > 6.0)

Register the service provider in config/app.php

Byancode\Settings\Provider::class,

Add alias if you want to use the facade.

'Setting' => Byancode\Settings\Facade::class,

3. Publish

Publish config file.

php artisan vendor:publish --provider="Byancode\Settings\Provider"

4. Configure

You can change the options of your app from config/settings.php file

Usage

You can either use the helper method like settings('foo') or the facade Settings::get('foo')

Facade

# GETTER  
Settings::get('foo');    
Settings::get('foo.bar'); 
Settings::get('foo__bar');

# SETTER  
Settings::set('foo', ['bar' => 'test']);
Settings::set('foo.bar', 'test');

Helper

$settings = settings();

# GETTER 
settings('foo');
$settings->foo;
settings('foo.bar');
$settings->foo__bar;
$settings->get('foo.bar');

# SETTER  
settings('foo', ['bar' => 'test']);
$settings->foo = ['bar' => 'test'];
$settings->foo__bar = 'test';
$settings->set('foo.bar', 'test');

Blade Directive

You can get the settings directly in your blade templates using the helper method or the blade directive like @settings('foo')