Code Monkey home page Code Monkey logo

laravel-settings's Introduction

Latest Stable Version Total Downloads Latest Unstable Version License

Laravel-Settings

Laravel 5.1.x Persistent Settings (Database + Cache)

Attention

You can use v1.0.1 for laravel 5.x

How to Install

Require this package with composer (Packagist) using the following command:

composer require efriandika/laravel-settings

or modify your composer.json:

   "require": {
      "efriandika/laravel-settings": "1.*"
   }

then run composer update:

After updating composer, Register the ServiceProvider to the providers array in config/app.php

'Efriandika\LaravelSettings\SettingsServiceProvider',

Add an alias for the facade to aliases array in your config/app.php

'Settings'  => Efriandika\LaravelSettings\Facades\Settings::class,

You can publish the config and migration files now (Attention: This command will not work if you don't follow previous instruction):

$ php artisan vendor:publish --provider="Efriandika\LaravelSettings\SettingsServiceProvider" --force

Change config/settings.php according to your needs. If you change db_table, don't forget to change the table's name in the migration file as well.

Create the settings table.

$ php artisan migrate

How to Use it

Set a value

Settings::set('key', 'value');

Get a value

$value = Settings::get('key');

Get a value with Default Value.

$value = Settings::get('key', 'Default Value');

Note: If key is not found (null) in cache or settings table, it will return default value

Get a value via an helper

$value = settings('key');
$value = settings('key', 'default value');

Forget a value

Settings::forget('key');

Forget all values

Settings::flush();

To Do

License

The Laravel 5 Persistent Settings is open-sourced software licensed under the MIT license

laravel-settings's People

Contributors

efriandika avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.