Package Data | |
---|---|
Maintainer Username: | shipu |
Maintainer Contact: | shipuahamed@gmail.com (Shipu Ahamed) |
Package Create Date: | 2018-09-18 |
Package Last Update: | 2022-05-06 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-15 15:14:07 |
Package Statistics | |
---|---|
Total Downloads: | 177 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 6 |
Total Watchers: | 3 |
Total Forks: | 1 |
Total Open Issues: | 0 |
Persistent settings in Laravel
Setting is a Laravel package so you can install it via Composer. Run this command in your terminal from your project directory:
composer require shipu/settings
Now run this command in your terminal to publish this package resources:
php artisan vendor:publish --provider="Shipu\Settings\Providers\SettingsServiceProvider"
If you run vendor:publish
then you have add below code in your settings model
protected $table = 'site_settings'; // you can change your database table name.
public $timestamps = false;
Use GeTraits
traits in your model.
For getting all settings value paired by key you can use all
method.
YourSettingModel::all(); // return collection
For set value you can use set
method.
YourSettingModel::set('key', 'value'); // return null
Multiple data store by key
YourSettingModel::set(['key1' => 'value', 'key2' => ['subkey2' => 'value-of-subkey2'] ]); // return null
For get value you can use get
method.
YourSettingModel::get('key'); // return collection or string or null
Fallback Support:
YourSettingModel::get('key2.subkey2'); // return collection or string or null
You can also getting all setting value
YourSettingModel::get(); // return collection
For checking key exists or not you can use has
method.
YourSettingModel::has('key'); // return bool
Multiple key Forget:
YourSettingModel::has(['key1', 'key2']); // return collection
For delete key you can use forget
method.
YourSettingModel::forget('key'); // return integer 0 or 1
Multiple key Forget:
YourSettingModel::forget(['key1', 'key2']); // return interger - how many key successfully delete.