qwince/l5-settings

Persistent settings in Laravel.
237 1
Install
composer require qwince/l5-settings
Latest Version:v0.4.1
PHP:>=5.3.0
License:MIT
Last Updated:Sep 5, 2017
Links: GitHub  ·  Packagist
Maintainer: spitalia

Laravel Settings

Persistent, application-wide settings for Laravel.

Installation

  1. composer require qwince/l5-settings:dev-master
  2. Add qwince\LaravelSettings\SettingsServiceProvider::class, to the array of providers in config/app.php.
  3. Publish config file and migration by running php artisan vendor:publish --provider="qwince\LaravelSettings\SettingsServiceProvider".
  4. Optional: add 'Setting' => qwince\LaravelSettings\SettingsFacade::class, to the array of aliases in config/app.php.

Usage

Global settings

You can either access the setting store via its facade or inject it by type-hinting towards the abstract class qwince\LaravelSettings\SettingStore.

<?php
Setting::set('foo', 'bar');
Setting::get('foo', 'default value');
Setting::forget('foo');
$settings = Setting::all();
?>

User settings

Create a Setting model app/Setting.php using the following example:

<?php namespace App;

use qwince\LaravelSettings\SettingModel;

class Setting extends SettingModel
{
}

Next, use the SettingUserTrait trait in your existing User model. For example:

<?php
namespace App;
use qwince\LaravelSettings\Traits\SettingsUserTrait;

class User extends Authenticatable
{
    use SettingsUserTrait;
}

This will enable the relation with Setting and add the following methods settings(), hasSetting($key), getSetting($key), setSetting($key, $value, $description) activate($key) and deactivate($key) within your User model.

Contact

Open an issue on GitHub if you have any problems or suggestions.

License

The contents of this repository is released under the MIT license.

Related Packages

erirk/paypalpayment

laravel-paypalpayment is simple package help you process direct credit card paym...

0
gabrieloliverio/laravel5-generators

Database metadata-based generators for Laravel 5

1
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

617,346,630 9,703
laravel/framework

The Laravel Framework.

561,395,438 34,860
laravel/tinker

Powerful REPL for the Laravel framework.

471,804,685 7,440