<?php

namespace App\Controllers;
use App\Models\common\MenuModel;

use App\Models\manage\UserModel;
use CodeIgniter\Controller;

abstract class BaseController extends Controller
{
    protected $helpers = ['array', 'function', 'cookie'];

    protected $session;
    protected $data = [];


    public function initController($request, $response, $logger)
    {
        parent::initController($request, $response, $logger);

        $this->session = \Config\Services::session();

        // 메뉴 전역 로딩
        $menuModel = new MenuModel();
        $menus = $menuModel->getMenuList(session('usr_level'));
        $this->data['menus'] = $menus["mainMenu"];


        if (!empty(session('usr_id'))) {
            // 비밀번호 변경일 체크
            $userModel = new UserModel();
            $usr_id = session('usr_id');
            $diff = $userModel->chkChgPwDiff($usr_id);

            if ($diff >= 180) {
                $this->data['pwExpire'] = true;
            } else {
                $this->data['pwExpire'] = false;
            }
        }

    }
}
