|
1 | 1 | # [Apiato](https://github.com/apiato/apiato) Settings Container |
2 | 2 |
|
3 | | -An Apiato container which helps store and retrieving key values |
| 3 | +#### An Apiato container which helps store and retrieving key values |
4 | 4 |
|
5 | | -At many cases you need to have some dynamic system settings, such as in a referral program, where you give 'gifts' to anyone who refers new users. |
6 | | -But those gifts can be changed in the future, so it's better not have them statically created in the code, instead read from the database where an Admin can manage them at any time. |
7 | | - |
8 | | -This container helps to store and retrieve those key values settings. You can also seed the database with the default configurations. |
9 | | - |
10 | | -#### Compatiblity table |
11 | | - |
12 | | -| Container Version | Apiato Version| |
13 | | -| -------------------|---------------| |
14 | | -| `^2.*.*` | `^10.*.*` | |
15 | | - |
16 | | -- [Installation](#installation) |
17 | | -- [Seed the default settings](#seed-the-default-settings) |
18 | | -- [Read settings](#read-settings) |
19 | | - |
20 | | -<a name="installation"></a> |
21 | | -## Installation |
22 | | - |
23 | | -``` |
24 | | -composer require apiato/settings-container |
25 | | -``` |
26 | | -Now run `php artisan migrate` |
27 | | - |
28 | | -<a name="seed-the-default-settings"></a> |
29 | | - |
30 | | -## Seed the default settings |
31 | | - |
32 | | -1) Copy the container from `Vendor` to a section of your project and fix the namespaces. |
33 | | -2) Seed default settings in `app/Containers/YourSection/Settings/Database/Seeders/DefaultSystemSettingsSeeder.php` |
34 | | - |
35 | | -<a name="read-settings"></a> |
36 | | - |
37 | | -## Read settings |
38 | | - |
39 | | -```php |
40 | | -<?php |
41 | | -$value = $this->findSettingsByKeyTask->run('whateverSettingsName'); |
42 | | -``` |
43 | | - |
44 | | -You can search for settings by Key as in the example above, or create a class for each settings as follow: |
45 | | - |
46 | | -```php |
47 | | -<?php |
48 | | -$value = $this->findWhateverSettingsTask->run(); |
49 | | -``` |
| 5 | +Read more about it in Apiato [docs](http://apiato.io/docs/additional-features/apiato-containers/settings). |
0 commit comments