1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-28 13:21:37 +08:00
course-tencent-cloud/app/Caches/SectionConfig.php
2020-03-30 19:35:49 +08:00

42 lines
695 B
PHP

<?php
namespace App\Caches;
use App\Repos\Config as ConfigRepo;
class SectionConfig extends Cache
{
protected $lifetime = 365 * 86400;
public function getLifetime()
{
return $this->lifetime;
}
public function getKey($id = null)
{
return "section_config:{$id}";
}
public function getContent($id = null)
{
$configRepo = new ConfigRepo();
$items = $configRepo->findAll(['section' => $id]);
if ($items->count() == 0) {
return [];
}
$result = [];
foreach ($items as $item) {
$result[$item->item_key] = $item->item_value;
}
return $result;
}
}