Download the PHP package fantismic/dynamic-settings without Composer
On this page you can find all versions of the php package fantismic/dynamic-settings. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fantismic/dynamic-settings
More information about fantismic/dynamic-settings
Files in fantismic/dynamic-settings
Package dynamic-settings
Short Description This package creates custom dynamic settings controlled by the user.
License MIT
Informations about the package dynamic-settings
Dynamic Settings
Dynamic Settings is a Laravel / Livewire package that allows you to manage custom settings of your application dynamically.
Let's say you have several notifications to different mailing lists, but you would like to be able to change whether they are sent or not, or which email they are sent to without having to modify the code or the env file.
This is where Dynamic Settings comes in.
You can make any number of configurations, grouped and associated with each other, and then use their values in the code. This way when sending an email, for example, $to will be DynSettings::get('admin.mail') and not "[email protected]".
Requirements
- Laravel 10/11
Optionals requirements
- Livewire 3 (*)
- Wire UI 2 (**)
(*) Livewire 3 is required only for the component to manage the settings. You can always ignore that and make your own.
(**) As said before, WireUI is a great package for those components, we included a normal view and a WireUI view, they set up automatically base on your app.
Installation
After you install you need to publish the migration file...
...and run the migration.
That's it. You are ready to go!
Optionals
You can publish the configuration file to customize behavior, such as full page component mode or preferred blade.
Using the built in component
Component mode
We provide a livewire component for manage the settings. You just need to include it like any other componenet wherever you want it.
Fullpage mode
You can set the component to render in fullpage in the config file. If you do, you should add the route in your routes/web.php
Usage
We provide one or two methods in the facade.
Lets say you have these keys:
Getting data
- Get all settings
- Get all settings as array
- Get all settings as object
- Get all settings as dotted array
- Get setting value
- Get setting data
- Get setting model
- Get all groups
- Get associations by group
- Get settings by group
Setting / Updating data
- Set a value
- Get settings by group
- Update groupname
- Update description
- Update association
- Delete setting
- Delete setting by key
- Update groupname
Using the settings
- Comparing setting
- Boolean comparition
- Array search
Get all settings
DynSettings::all(): (array)
Get all settings as array
DynSettings::getArray(): (array)
Get all settings as object
DynSettings::getObject(): (object)
Get all settings as dotted array
DynSettings::getDot(): (array)
Get setting value
DynSettings::get( (string) $key): (mixed)
Get setting data
DynSettings::getKeyData( (string) $key): (array)
Get setting model
DynSettings::getModel( (string) $key): (Eloquent Model)
Get all groups
DynSettings::getGroups(): (array)
Get associations by group
DynSettings::getAssocs( (string) $group): (array)
Get settings by group
DynSettings::getByGroup( (string) $group): (array)
Setting / Updating data
Set a value
DynSettings::set( (string) $group, (mixed) $value): (bool)
Update groupname
DynSettings::updateName( (string) $key, (string) $newName): (bool)
Update description
DynSettings::updateDescription( (string) $key, (string) $newDescription): (bool)
Update association
DynSettings::updateAssoc( (string) $key, (string) $newAssoc): (bool)
Delete setting
DynSettings::delete( (int) $id)**: (bool)
Delete setting by key
DynSettings::deleteByKey( (string) $key)**: (bool)
Update groupname
DynSettings::updateGroupName( (string) $oldName, (string) $newName): (bool)
Using the settings
Comparing setting
DynSettings::is( (string) $key, (mixed) $value): (bool)
Boolean comparition
DynSettings::should( (string) $key): (bool)
Array search
DynSettings::has( (string) $key, (array) $value, [(bool) strict = false]): (bool)