This package is used for adding field options to system and configuring the api throttle.
- Unzip all the files to packages/GGPHP/Config.
- Open
config/app.php
and add GGPHP\Config\Providers\ConfigServiceProvider::class. - Open
composer.json
of root project and add "GGPHP\Config\": "packages/GGPHP/Config/src". - Run the following command
composer update
composer dump-autoload
You are now able to add the new fields for system.
-
Configure
STORE_DB=firebase
andFIREBASE_CREDENTIALS={file-path}
at.env
file, default isdatabase
. -
Go to https:///configuration/field/edit, edit value and save, data will dispatch to real time database on firebase.
-
Use
retrieveData($reference)
function in FirebaseService to get data by $reference.
$results = retrieveData('configuration/system/fields')
- Use
getDataByCode($code)
function in FirebaseService to get data by $code (code name)
$results = getDataByCode('firebase')
- Use
uploadFile($file, $type, $reference, $expiresAt)
function in FirebaseService to upload file.
$image = $request->file('image'); //image file from frontend
$type = image/png;
$reference = 'images';
$expiresAt = 'today';
$results = uploadFile($image, $type, $reference, $expiresAt)
- Use
getFile($reference)
function in FirebaseService to get url and file info.
$reference = 'images';
$results = getFile($reference);
- Open
packages/GGPHP/Config/config/system.php
and add config data tofields
(refer configuration at example data) - Go to
ConfigController.php
file and override$userRole
variable (allow user can edit) then add role to the fieldsGGPHP\Config\config\system
. - Go to
https://<your-site>/configuration/field/edit
, edit value then save.
- Use
getConfigByCode
method to get field data.
$results = getDataByCode('firebase')
- Add
throttle
tomiddleware
atprefix => api
. - Go to
https://<your-site>/configuration/throttles
to view all apis in the system. - Click to
Edit
button to editMax Attempts
andDecay Minutes
.
- Use
GET
method |https://<your-site>/api/configuration/fields
- Use
GET
method |https://<your-site>/api/configuration/fields/{id}
- Use
PATCH
method |https://<your-site>/api/configuration/fields/reset
{
"id" : 1,
"code": "test",
"value": {
"max_attempts": 60,
"decay_minutes": 1
},
"type": "text"
}
- Use
GET
|https://<your-site>/api/configuration/fields/reset
- Use
GET
method |https://<your-site>/api/configuration/throttles
- Use
GET
method |https://<your-site>/api/configuration/throttles/{name}
- Use
GET
method |https://<your-site>/api/configuration/throttles/reset
- Use
POST
method |https://<your-site>/api/configuration/throttles
{
"name": "Route name",
"max_attempts": 30,
"decay_minutes": 1
}
composer test
Field options:
[
'code' => 'text-field',
'type' => 'text',
'name' => 'Text field',
'title' => 'title field',
'default' => 'default value',
'access' => ['admin'],
],
[
'code' => 'number-field',
'type' => 'number',
'name' => 'Number field',
'title' => 'title field',
'default' => 'default value',
'validation' => 'required|min:1',
'access' => ['user'],
],
[
'code' => 'boolean-field',
'type' => 'boolean',
'name' => 'Boolean field',
'title' => 'title field',
'default' => false,
'value' => true,
'access' => ['admin'],
],
[
'code' => 'selection field',
'type' => 'select',
'name' => 'selection field',
'title' => 'title field',
'options' => [
[
'title' => 'option 1',
'value' => 1
],
[
'title' => 'option 2',
'value' => 2
]
...
]
],
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.