1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-07-13 03:49:11 +08:00
course-tencent-cloud/app/Caches/CategoryList.php
koogua 0336a54911 1.源文件增加版权信息
2.群组状态和课程协同
2021-06-13 15:49:47 +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 CategoryList extends Cache
{
protected $lifetime = 365 * 86400;
public function getLifetime()
{
return $this->lifetime;
}
public function getKey($type = null)
{
return "category_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])
->andWhere('published = 1')
->execute();
if ($categories->count() == 0) {
return [];
}
return $categories->toArray();
}
}