All Projects → akaunting → Laravel Setting

akaunting / Laravel Setting

Licence: mit
Persistent settings package for Laravel

Projects that are alternatives of or similar to Laravel Setting

Config
Manage Laravel configuration by persistent storage
Stars: ✭ 139 (-50%)
Mutual labels:  config, persistent, laravel
Laravel Settings
Persistent key-value storage for Laravel, json value supported. l10n supported.
Stars: ✭ 101 (-63.67%)
Mutual labels:  config, laravel
Rime pure
【rime小狼毫\trime同文】手机/PC一站式配置【简约皮肤\拼音搜狗词库\原创trime同文四叶草九宫格拼音方案\四叶草拼音、小鹤双拼、极品五笔、徐码、郑码】 rime配置
Stars: ✭ 73 (-73.74%)
Mutual labels:  config, settings
Dynaconf
Configuration Management for Python ⚙
Stars: ✭ 2,082 (+648.92%)
Mutual labels:  config, settings
Node Config
Node.js Application Configuration
Stars: ✭ 5,423 (+1850.72%)
Mutual labels:  config, settings
Qonfig
Config. Defined as a class. Used as an instance. Lazy instantiation. Validation layer. Thread-safe. Support for YAML, TOML, JSON, __END__, ENV. Extremely simple to define. Extremely simple to use.
Stars: ✭ 17 (-93.88%)
Mutual labels:  config, settings
Config
Config manager for laravel-admin
Stars: ✭ 83 (-70.14%)
Mutual labels:  config, laravel
configster
Rust library for parsing configuration files
Stars: ✭ 19 (-93.17%)
Mutual labels:  config, settings
plaster
Application config settings abstraction layer.
Stars: ✭ 19 (-93.17%)
Mutual labels:  config, settings
Simple Settings
A simple way to manage your project settings.
Stars: ✭ 165 (-40.65%)
Mutual labels:  config, settings
Laravel App Settings
Store settings in database with a manager UI for your Laravel app
Stars: ✭ 220 (-20.86%)
Mutual labels:  settings, laravel
climatecontrol
Python library for loading settings and config data from files and environment variables
Stars: ✭ 20 (-92.81%)
Mutual labels:  config, settings
Nova Settings Tool
Laravel Nova tool to view and edit application settings.
Stars: ✭ 131 (-52.88%)
Mutual labels:  settings, laravel
Ins sandstorm
[INS] Config setting for our sandstorm server
Stars: ✭ 61 (-78.06%)
Mutual labels:  config, settings
Laravel Property Bag
Add settings to any Laravel model.
Stars: ✭ 78 (-71.94%)
Mutual labels:  settings, laravel
Eloquent Settings
Eloquent Settings allows you to bind key-value pairs to any Laravel Eloquent model. It supports even casting for boolean, float or integer types.
Stars: ✭ 71 (-74.46%)
Mutual labels:  settings, laravel
Laravel Model Settings
Model Settings for your Laravel app
Stars: ✭ 409 (+47.12%)
Mutual labels:  settings, laravel
Laravel Settings
Simple Settings package for a laravel application
Stars: ✭ 45 (-83.81%)
Mutual labels:  settings, laravel
Dotfiles
Config for vim sublime awesome xmonad etc.
Stars: ✭ 140 (-49.64%)
Mutual labels:  config, settings
cfg-rs
A Configuration Library for Rust Applications
Stars: ✭ 18 (-93.53%)
Mutual labels:  config, settings

Persistent settings package for Laravel

Downloads StyleCI Quality License

This package allows you to save settings in a more persistent way. You can use the database and/or json file to save your settings. You can also override the Laravel config.

  • Driver support
  • Helper function
  • Blade directive
  • Override config values
  • Encryption
  • Custom file, table and columns
  • Auto save
  • Extra columns
  • Cache support

Getting Started

1. Install

Run the following command:

composer require akaunting/laravel-setting

2. Register (for Laravel < 5.5)

Register the service provider in config/app.php

Akaunting\Setting\Provider::class,

Add alias if you want to use the facade.

'Setting' => Akaunting\Setting\Facade::class,

3. Publish

Publish config file.

php artisan vendor:publish --tag=setting

4. Database

Create table for database driver

php artisan migrate

5. Configure

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

Usage

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

Facade

Setting::get('foo', 'default');
Setting::get('nested.element');
Setting::set('foo', 'bar');
Setting::forget('foo');
$settings = Setting::all();

Helper

setting('foo', 'default');
setting('nested.element');
setting(['foo' => 'bar']);
setting()->forget('foo');
$settings = setting()->all();

You can call the save() method to save the changes.

Auto Save

If you enable the auto_save option in the config file, settings will be saved automatically every time the application shuts down if anything has been changed.

Blade Directive

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

Override Config Values

You can easily override default config values by adding them to the override option in config/setting.php, thereby eliminating the need to modify the default config files and also allowing you to change said values during production. Ex:

'override' => [
    "app.name" => "app_name",
    "app.env" => "app_env",
    "mail.driver" => "app_mail_driver",
    "mail.host" => "app_mail_host",
],

The values on the left corresponds to the respective config value (Ex: config('app.name')) and the value on the right is the name of the key in your settings table/json file.

Encryption

If you like to encrypt the values for a given key, you can pass the key to the encrypted_keys option in config/setting.php and the rest is automatically handled by using Laravel's built-in encryption facilities. Ex:

'encrypted_keys' => [
    "payment.key",
],

JSON Storage

You can modify the path used on run-time using setting()->setPath($path).

Database Storage

If you want to use the database as settings storage then you should run the php artisan migrate. You can modify the table fields from the create_settings_table file in the migrations directory.

Extra Columns

If you want to store settings for multiple users/clients in the same database you can do so by specifying extra columns:

setting()->setExtraColumns(['user_id' => Auth::user()->id]);

where user_id = x will now be added to the database query when settings are retrieved, and when new settings are saved, the user_id will be populated.

If you need more fine-tuned control over which data gets queried, you can use the setConstraint method which takes a closure with two arguments:

  • $query is the query builder instance
  • $insert is a boolean telling you whether the query is an insert or not. If it is an insert, you usually don't need to do anything to $query.
setting()->setConstraint(function($query, $insert) {
	if ($insert) return;
	$query->where(/* ... */);
});

Custom Drivers

This package uses the Laravel Manager class under the hood, so it's easy to add your own storage driver. All you need to do is extend the abstract Driver class, implement the abstract methods and call setting()->extend.

class MyDriver extends Akaunting\Setting\Contracts\Driver
{
	// ...
}

app('setting.manager')->extend('mydriver', function($app) {
	return $app->make('MyDriver');
});

Changelog

Please see Releases for more information what has changed recently.

Contributing

Pull requests are more than welcome. You must follow the PSR coding standards.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see LICENSE for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].