1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-22 19:44:02 +08:00
xiaochong0302 1bef24f217 1.kg_course表增加索引
2.优化错误页
3.优化富文本内容长度获取
4.优化layer关闭窗口后发布状态同步
2023-09-16 20:51:31 +08:00

50 lines
1.0 KiB
PHP

<?php
/**
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
namespace App\Builders;
use App\Caches\CategoryAllList as CategoryAllListCache;
use App\Models\Category as CategoryModel;
class HelpList extends Builder
{
public function handleCategories(array $helps)
{
$categories = $this->getCategories();
foreach ($helps as $key => $help) {
$helps[$key]['category'] = $categories[$help['category_id']] ?? new \stdClass();
}
return $helps;
}
public function getCategories()
{
$cache = new CategoryAllListCache();
$items = $cache->get(CategoryModel::TYPE_HELP);
if (empty($items)) {
return [];
}
$result = [];
foreach ($items as $item) {
$result[$item['id']] = [
'id' => $item['id'],
'name' => $item['name'],
];
}
return $result;
}
}