LaravelPackages.net
Acme Inc.
Toggle sidebar
shipu/settings

Settings is persistent settings in laravel

181
6
v1.2
About shipu/settings

shipu/settings is a Laravel package for settings is persistent settings in laravel. It currently has 6 GitHub stars and 181 downloads on Packagist (latest version v1.2). Install it with composer require shipu/settings. Discover more Laravel packages by shipu or browse all Laravel packages to compare alternatives.

Last updated

Settings

Persistent settings in Laravel

Features

  • Settings

Installation

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 Traits

Use GetSettings traits in your model.

API List

getAll

For getting all settings value paired by key you can use all method.

YourSettingModel::getAll(); // return collection

set

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

get

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

has

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

forget

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.

Star History Chart