System Settings 本文未发布 发布文章

未匹配的标注

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. 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.
The app/Containers/Settings Container helps storing and retrieving those key values settings. It also seed the database with the default configurations during the installation.

Seed the default settings

Default Settings should be seeded in app/Containers/Settings/Database/Seeders/DefaultSystemSettingsSeeder.php

Read settings

<?php
$value = $this->findSettingsByKeyTask->run('whateverSettingsName');

You can search for settings by Key as in the example above, or create a class for each settings as follow:

<?php
$value = $this->findWhateverSettingsTask->run();

本文章首发在 LearnKu.com 网站上。

上一篇 下一篇
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
讨论数量: 0
发起讨论 查看所有版本


暂无话题~