ASetting is a Laravel package that allows you to manage settings dynamically in your Laravel applications. With this package, you can organize settings in groups stored in the database, supporting various types of settings for easy management.
- Introducing an interactive blade page where users can view and modify application settings. With this feature, users will be able to customize the behavior and preferences of the application according to their needs.
You can add the ASetting package to your Laravel project by following the steps below.
Add the package to your project using Composer.
composer require aurorawebsoftware/asetting
To publish the configuration file, run the following command:
php artisan vendor:publish --tag=asetting-config
This will add the config/asetting.php
file to your project, which contains the configuration settings for the ASetting package.
Run the migration to create the database table used to store settings:
php artisan migrate
The ASetting Facade allows you to easily manage settings. Below are some basic functions and features provided by the Facade.
Used to work with settings in a specific group.
ASetting::group('site')->getValue('title');
Used to work with settings in multiple groups.
ASetting::groups(['site', 'mail'])->all();
Used to get the value of a specific setting.
ASetting::group('site')->getValue('title');
Used to get the title of a specific setting.
ASetting::group('site')->getTitle('title');
Used to check the visibility status of a specific setting.
ASetting::group('site')->isVisible('title');
Used to get all information about a specific setting.
ASetting::group('site')->get('title');
Used to get the values of a specific setting.
ASetting::group('site')->getValues(['title','name']);
Used to get the values of a specific settings.
ASetting::groups(['site','general'])->getValues(['title','name']);
set(string $key, string|int|bool|array $value, string|null $title = null, bool|null $isVisible = null): bool|array
Used to update or create the value of a specific setting.
ASetting::group('site')->set('title', 'New Title', 'Site Title', true);
Used to delete a specific setting.
ASetting::group('site')->delete('title');
Used to get all settings grouped by groups or under a specific group.
ASetting::all(); // Get all settings
ASetting::group('site')->all(); // Get all settings under a specific group
Used to delete all settings under a specific group.
ASetting::group('site')->destroy();
ASetting::groups(['site','general'])->destroy();
add(string $group, string $key, string|int|bool|array $value, string $title = null, string $type = 'string', bool $isVisible = null): ASettingModel|SettingNotFoundException
Used to add a new setting.
ASetting::add('site', 'new_setting', 'Value', 'Setting Title', 'string', true);
You can define tokens for APIs. You can also configure it by adding your own middleware.
return [
'api_token' => ['YOUR_BEARER_TOKEN_HERE'],
'api_middleware' => [
// YourMiddlewareClass::class
]
];
- Endpoint:
/api/asetting/getValue/{group}/{key}
- Method: GET
- Parameters:
group
(string),key
(string)
- Endpoint:
/api/asetting/getTitle/{group}/{key}
- Method: GET
- Parameters:
group
(string),key
(string)
- Endpoint:
/api/asetting/isVisible/{group}/{key}
- Method: GET
- Parameters:
group
(string),key
(string)
- Endpoint:
/api/asetting/get/{group}/{key}
- Method: GET
- Parameters:
group
(string),key
(string)
- Endpoint:
/api/asetting/getValues
- Method: POST
- Parameters:
group
(string|array),keys
(array)
- Endpoint:
/api/asetting/set
- Method: PUT
- Parameters:
group
(string),key
(string),value
(string|array),title
(string, optional),is_visible
(bool, optional)
- Endpoint:
/api/asetting/add
- Method: POST
- Parameters:
group
(string),key
(string),value
(string|array|bool|int),type
(string),title
(string),is_visible
(bool, optional)
- Endpoint:
/api/asetting/all/{group?}
- Method: GET
- Parameters:
group
(string, optional)
- Endpoint:
/api/asetting/delete/{group}/{key}
- Method: DELETE
- Parameters:
group
(string),key
(string)
- Endpoint:
/api/asetting/destroy/{group}
- Method: DELETE
- Parameters:
group
(string)
In case of invalid requests or errors, the API will return a JSON response with a corresponding message and, if applicable, validation errors.
Feel free to copy and paste this documentation into your README file. Adjust the formatting as needed.
This command allows you to interact with the ASetting package.
php artisan asetting {group=null} {key=null}
This command allows you to interact with the ASetting package.
- Fetch a specific setting value:
php artisan asetting myGroup myKey
- Fetch all settings in a specific group:
php artisan asetting myGroup
- Fetch all settings:
php artisan asetting
- If the specified group or key is not found, an exception message will be displayed.
- The command returns the setting value, which can be a string, array, or other types, based on the configuration.
The ASetting package is licensed under the MIT License.