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

51 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\Caches;
use App\Models\Category as CategoryModel;
use Phalcon\Mvc\Model\Resultset;
class CategoryAllList extends Cache
{
protected $lifetime = 365 * 86400;
public function getLifetime()
{
return $this->lifetime;
}
public function getKey($type = null)
{
return "category_all_list:{$type}";
}
/**
* @param null $type
* @return array
*/
public function getContent($type = null)
{
/**
* @var Resultset $categories
*/
$categories = CategoryModel::query()
->columns(['id', 'parent_id', 'name', 'priority', 'level', 'path'])
->where('type = :type:', ['type' => $type])
->orderBy('level ASC, priority ASC')
->execute();
if ($categories->count() == 0) {
return [];
}
return $categories->toArray();
}
}