webafra/larasettings

Store your custom Settings in database and cache system

dev-master 2019-01-07 14:03 UTC

This package is not auto-updated.

Last update: 2024-11-05 20:03:31 UTC


README

#Laravel Setting

install via composer

composer require webafra/larasettings

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

'providers' => [
    ....
    Webafra\LaraSetting\LaraSettingServiceProvider::class,
]

And add alias to aliases array:

'aliases' => [
    ...
    'Setting' => Webafra\LaraSetting\Facade\Setting::class,
]

Usage

<?php
namespace App\Http\Controllers;

use Webafra\LaraSetting\Facade\Setting;

class SettingController extends Controller {
    public function index(){
        #Set a Setting property:
        Setting::set('key', 'value');
        
        #Set a Setting property and Set is_primary:
        Setting::set('key', 'value', true);
        
        #Get a Stored Setting value or pass default value
        $setting['key'] = Setting::get('key', 'default value');
    }
    
    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'));
        
        
        #get all settings from an key-value and is primary data array and store them to database
        #example: <input type="text" name="setting['title']">
        Setting::storePrimary($request->input('setting'));


        # and you want Clear All Cache Data With Artisan command Line :
        Setting::clean();
    }
}