123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- declare(strict_types=1);
- /**
- * @file Index.php
- * @date 2019-02-27 14:49:36
- * @author huwhis<huuwhois>
- * @version 0.0.6
- */
- namespace app\index\controller;
- use think\facade\View;
- use think\App;
- use app\common\model\Article;
- use app\common\model\Category;
- use think\facade\Env;
- abstract class Base
- {
- /**
- * Request实例
- * @var \think\Request
- */
- protected $request;
- /**
- * 应用实例
- * @var \think\App
- */
- protected $app;
- /**
- * 构造方法
- * @access public
- * @param App $app 应用对象
- */
- public function __construct(App $app)
- {
- $this->app = $app;
- $this->request = $this->app->request;
- // 控制器初始化
- $this->initialize();
- }
- // 初始化
- protected function initialize()
- {
- // 菜单
- $categories = Category::where('is_nav', 1)->order(['sort desc'])->select();
- View::assign('categories', $categories);
- if ($this->request->has('_aside')==false) {
- $this->aside();
- }
- }
- /**
- * 侧边栏
- */
- protected function aside()
- {
- $cate_lists = Category::where('template', 'article')->select();
- $hits_lists = Article::getListByCid(0, 9, ['hits' => 'desc']);
- $top_lists = Article::getTop(7);
- $time_lists = Article::createTimeArchive();
- View::assign([
- 'cate_lists' => $cate_lists,
- 'hits_lists' => $hits_lists,
- 'top_lists' => $top_lists,
- 'time_lists' => $time_lists
- ]);
- }
- }
|