<?php

namespace app\admin\controller;

use think\Controller;
use think\Request;
use think\Session;

class Common extends Controller {
    protected $controller_name;
    protected $model_data;  //获取当前model数据信息
    public function _initialize()
    {
        parent::_initialize(); // TODO: Change the autogenerated stub

        //登录检测
        if(!Session::has('admin.username')){
            $this->redirect('Login/index');
        }
        $this->setting=model('setting')->getSetting();
        $this->assign('setting',$this->setting);

        $request= Request::instance();
        $this->controller_name=strtolower($request->controller());
        //根据当前controller获取模型数据
        $this->model_data=model('models')->adminGetModelDataToTableName(strtolower($request->controller()));

    }
}