Package Data | |
---|---|
Maintainer Username: | spitalia |
Maintainer Contact: | gianluca@qwince.com (Gianluca Di Gesaro) |
Package Create Date: | 2016-11-06 |
Package Last Update: | 2017-09-05 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-27 15:03:15 |
Package Statistics | |
---|---|
Total Downloads: | 161 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 6 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Persistent, application-wide settings for Laravel.
composer require qwince/l5-settings:dev-master
qwince\LaravelSettings\SettingsServiceProvider::class,
to the array of providers in config/app.php
.php artisan vendor:publish --provider="qwince\LaravelSettings\SettingsServiceProvider"
.'Setting' => qwince\LaravelSettings\SettingsFacade::class,
to the array of aliases in config/app.php
.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();
?>
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.
Open an issue on GitHub if you have any problems or suggestions.
The contents of this repository is released under the MIT license.