<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;

use app\admin\model\LinkModel;
use app\admin\model\SlideItemModel;
use app\portal\model\PortalPostModel;
use cmf\controller\HomeBaseController;

class IndexController extends HomeBaseController
{
    public function index()
    {
        $this->getTopNav();
        $data = [];

        //轮播图
        $data['slide'] = SlideItemModel::where('slide_id', 1)->where('status', 1)->order('list_order', 'asc')->select();

        //文章
        $portalModel  = new PortalPostModel();
        $post = $portalModel->getListByCategory(0, 4);
        foreach ($post as $v) {
            $v['post_content'] = strip_tags($v['post_content']);
            $v['update_time'] = date('Y-m-d H:i:s',$v['update_time']);
        }
        $data['post'] = $post;

        //友情链接
        $link = LinkModel::where('status', 1)->order('list_order', 'asc')->select();
        $this->assign('link', $link);

        return $this->fetch(':index', $data);
    }
}
