howlowck / settings-l4
Installs: 14
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/howlowck/settings-l4
Requires
- php: >=5.4.0
- howlowck/html-builder: *
- illuminate/support: ~4
This package is not auto-updated.
Last update: 2025-10-20 19:10:44 UTC
README
This package is created to easily change application-level settings that Administator can change.
Setup
- Include
"howlowck/settings-l4": "dev-master",in your application composer.json - run
composer update - Add service provider by adding
'Howlowck\SettingsL4\SettingsL4ServiceProvider',inapp/config/app.php - Add Setting Facade by adding
'Setting' => 'Howlowck\SettingsL4\Facade\Setting'inapp/config/app.php - Run
php artisan config:publish howlowck/settings-l4 - generate your own migration with the table name 'settings'. (if you want to use a table named other than 'settings', please change the 'table' config item in the configuration file)
- generate a seed for one row of data. (it's required for settings to work properly)
Configuration
In app/config/howlowck/settings-l4/config.php
table --- table name
db --- whether to use db or redis
user_column --- the column name of user if you want to capture who changed the setting (not implemented)
controller --- the controller name
route_path --- the route path to get to the settings resource controller
route_before --- the filter string for before running to the route
route_after --- the filter string after running to the route
form_types --- the associated array for the input types are is associated with the database data fields, * is default
To Use
The Settings Package allows you to interact your settings in various ways.
Basic Usage
Setting::get($settingName) returns the value of the setting with that name
Setting::set($settingName, $settingValue) sets the value to the setting name
Setting::all() returns all the settings in an array
Built-in views and Routes
- Include
Setting::route()in your routes.php this will set up a route group for your settings controller. You can change the path and before/after filters in the config file. - Copy the Settings Controller from
vendors/howlowck/settings-l4/src/controllers/SettingsController.phpto your controllers folder. Feel free to change the name of the controller to anything you like, you just have to change the 'controller' configuration item in the config file. - Run
php artisan asset:publish howlowck/settings-l4 - Now when you go to any path with
path/to/settings/settingName/edityou will see a UI that allows you to edit the value.
The available paths are only path/to/settings and path/to/settings/settingName
Making your own views
If you prefer to make your own views you can use the following
Setting::getTitle($settingName) --- gives you the title of the setting
Setting::getField($settingName) --- gives you the field of the setting
Settings::getUpdateUrl($settingName) --- gives you the correct url to put in your form action property