Category.php 795 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace app\common\model\article;
  3. use think\Cache;
  4. use app\common\model\BaseModel;
  5. /**
  6. * 文章分类模型
  7. * Class Category
  8. * @package app\common\model
  9. */
  10. class Category extends BaseModel
  11. {
  12. protected $name = 'article_category';
  13. /**
  14. * 所有分类
  15. * @return mixed
  16. */
  17. public static function getALL()
  18. {
  19. $model = new static;
  20. if (!Cache::get('article_category_' . $model::$wxapp_id)) {
  21. $data = $model->order(['sort' => 'asc', 'create_time' => 'asc'])->select();
  22. $all = !empty($data) ? $data->toArray() : [];
  23. Cache::tag('cache')->set('article_category_' . $model::$wxapp_id, $all);
  24. }
  25. return Cache::get('article_category_' . $model::$wxapp_id);
  26. }
  27. }