<?php

namespace app\index\controller;

use app\model\Category;
use app\model\Nav;
use app\model\Post;
use think\facade\View;
use think\helper\Str;

class Common extends BaseController
{
  public function initialize()
  {
    parent::initialize();


    $list_nav_slide = Nav::where('type', 3)->order('sort asc')->where('status', 1)->select();
    View::assign('list_nav_slide', $list_nav_slide);
    $list_nav_friend_url = Nav::where('type', 2)->order('sort asc')->where('status', 1)->select();
    View::assign('list_nav_friend_url', $list_nav_friend_url);

    $list_header_nav = Nav::where('type', 11)->order('sort asc')->where('status', 1)->select();
    View::assign('list_header_nav', $list_header_nav);

    $list_category_first_level = Category::where('level', 1)->where('status', 1)->where('type',3)->select();
    View::assign('list_category_first_level', $list_category_first_level);
    $list_nav_more = Nav::where('type', 8)->order('sort asc')->where('status', 1)->select();
    View::assign('list_nav_more', $list_nav_more);

    $top_posts = Post::where('is_top',1)->limit(8)->where('type',3)->select();
    View::assign('top_posts',$top_posts);

  }

}
