Skip to content

⚙️ Package for managing settings in a Laravel projects

License

Notifications You must be signed in to change notification settings

kolirt/laravel-settings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Settings

Package for managing settings in a Laravel projects

Structure

Buy Me A Coffee

Getting started

Requirements

  • PHP >= 8.1
  • Laravel >= 10

For lesser versions of Laravel or PHP, use the v1

Installation

composer require kolirt/laravel-settings

Setup

php artisan settings:install

php artisan migrate

Console commands

  • settings:install - Install settings package
  • settings:publish-config - Publish the config file
  • settings:publish-migrations - Publish migration files
  • settings:flush-cache - Flush cache

Methods

set

The set method is used to set a value in the settings

use Kolirt\Settings\Facades\Setting;

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

Setting::set('array', [0, 1, 2]);
Setting::set('array.0', 'new value with index 0');

all

The all method is used to get all settings

use Kolirt\Settings\Facades\Setting;

Setting::all();
/**
 * Returns
 * 
 * [
 *   'string' => 'value',
 *   'array' => ['new value with index 0', 1, 2]
 * ]
 */

get

The get method is used to get a value from the settings

use Kolirt\Settings\Facades\Setting;

Setting::get('string'); // 'value'

Setting::get('array'); // ['new value with index 0', 1, 2]
Setting::get('array.0'); // 'new value with index 0'

// or via helper

setting('string'); // 'value'

setting('array'); // ['new value with index 0', 1, 2]
setting('array.0'); // 'new value with index 0'

delete

The delete method is used to delete a value from the settings

use Kolirt\Settings\Facades\Setting;

Setting::delete('string');

Setting::delete('array'); // delete all array values
Setting::delete('array.0'); // delete array value with index 0

flushCache

The flushCache method is used to flush the cache

use Kolirt\Settings\Facades\Setting;

Setting::flushCache();

FAQ

Check closed issues to get answers for most asked questions

License

MIT

Other packages

Check out my other packages on my GitHub profile