aries/laravelsetting

Store your custom Settings in database and cache system

0.2.5 2018-09-20 17:43 UTC

This package is auto-updated.

Last update: 2024-11-29 05:26:46 UTC


README

#Laravel Setting

install via composer

composer require aries/laravelsetting

Add Service Provider to config/app.php providers array:

'providers' => [
    ....
    Aries\LaravelSetting\LaravelSettingServiceProvider::class,
]

And add alias to aliases array:

'aliases' => [
    ...
    'Setting' => Aries\LaravelSetting\Facade\Setting::class,
]

And publish vendor

php artisan vendor:publish

And migrate database

php artisan migrate

Usage

<?php
namespace App\Http\Controllers;

use Aries\LaravelSetting\Facade\Setting;

class SettingController extends Controller {
    public function index(){
        #Set Primary Key :
        Setting::set('key', 'value', true);
    
        #Set a Setting property:
        Setting::set('key', 'value', false, false);
        
        #Get a Stored Setting value or pass default value
        $setting['key'] = Setting::get('key', 'default value');
        
        
        #Get All primary Keys
        $settings = Setting::getPrimary();
    }
    
    public function store(\Request $request){
        #get all settings from an key-value array and store them to database
        #example: <input type="text" name="setting['title']">
        Setting::store($request->input('setting'));
    }
}