<?php

namespace app\home\controller;

use app\common\model\NoticeModel;
use app\common\model\RecruitModel;
use app\common\model\RecruitNewsModel;
use app\common\model\SlideModel;
use app\home\HomeBaseController;

class Index extends HomeBaseController
{
    protected function init()
    {
        $this->tab = 'index';
    }

    public function index()
    {
        //轮播图
        $slide = SlideModel::where('tab', SlideModel::TAB_INDEX)
            ->where('status', SlideModel::STATUS_SHOW)
            ->order(['priority' => 'desc', 'id' => 'desc'])
            ->select();

        //政策
        $notice = NoticeModel::where('status', NoticeModel::STATUS_PUBLISH)
            ->order(['priority' => 'desc', 'update_time' => 'desc'])
            ->limit(10)
            ->select();

        //公告
        $news = RecruitNewsModel::with(['recruit'])
            ->where('status', RecruitNewsModel::STATUS_PUBLISH)
            ->order(['priority' => 'desc', 'update_time' => 'desc'])
            ->append(['summary', 'update_show'])
            ->limit(10)
            ->select();

        $recruit = RecruitModel::where('status', RecruitModel::STATUS_YES)
            ->order(['priority' => 'desc', 'update_time' => 'desc'])
            ->append(['current_text','apply_time'])
            ->limit(9)
            ->select();

        return view('', [
            'slide'   => $slide,
            'notice'  => $notice,
            'news'    => $news,
            'recruit' => $recruit,
        ]);
    }
}
