| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 | <?phpdeclare(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;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);        View::assign([            'cate_lists' => $cate_lists,            'hits_lists'  => $hits_lists,            'top_lists'  => $top_lists        ]);    }}
 |