Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/umobi/laravel-settings
https://github.com/umobi/laravel-settings
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/umobi/laravel-settings
- Owner: umobi
- License: mit
- Created: 2018-03-04T15:43:19.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-03-03T17:31:57.000Z (almost 5 years ago)
- Last Synced: 2024-11-23T04:21:24.906Z (2 months ago)
- Language: PHP
- Size: 46.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/umobi/laravel-settings.svg?branch=master)](https://travis-ci.org/umobi/laravel-settings)
# Persistent Settings Manager for Laravel
* Simple key-value storage
* Support multi-level array (dot delimited keys) structure.
* Localization supported.## Installation
1. Install package
```bash
composer require umobi/laravel-settings
```1. Edit config/app.php (Skip this step if you are using laravel 5.5+)
service provider:
```php
Umobi\Setting\SettingServiceProvider::class,
```class aliases:
```php
'Setting' => Umobi\Setting\SettingFacade::class,
```1. Create settings table
```bash
php artisan vendor:publish --tag=settings
php artisan migrate
```## Usage
```php
Setting::get('name', 'Computer');
// get setting value with key 'name'
// return 'Computer' if the key does not existsSetting::lang('zh-TW')->get('name', 'Computer');
// get setting value with key and languageSetting::set('name', 'Computer');
// set setting value by keySetting::lang('zh-TW')->set('name', 'Computer');
// set setting value by key and languageSetting::has('name');
// check the key exists, return booleanSetting::lang('zh-TW')->has('name');
// check the key exists by language, return booleanSetting::forget('name');
// delete the setting by keySetting::lang('zh-TW')->forget('name');
// delete the setting by key and language
```## Dealing with array
```php
Setting::get('item');
// return null;Setting::set('item', ['USB' => '8G', 'RAM' => '4G']);
Setting::get('item');
// return array(
// 'USB' => '8G',
// 'RAM' => '4G',
// );Setting::get('item.USB');
// return '8G';
``