<?php
/**
 * Created by PhpStorm.
 * User: hp
 * Date: 2017/12/1
 * Time: 11:37
 */

namespace App\Http\Controllers\Cp\Web;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class WelcomeController extends Controller
{

    public function index(Request $request)
    {
    	$domain = _domain();
    	$msg = $request->has('msg')?$request->get('msg'):'';
    	$options = [];
    
    	if(session('cp_manage_user'))
    	{
    		$manage_user = unserialize(session('cp_manage_user'));
//     		var_dump('$manage_user_sesiral');var_dump($manage_user);
    		$options =[
	    		'role'=>isset($manage_user['role'])?$manage_user['role']:''
    		];
    	}else{
    		return redirect()->to('/login');
    		exit();
    	}
//     	$options =[
//     	  'role'=>'admin'
//     	];
//     	var_dump('$options');var_dump($options);die();
    	$options = json_encode($options);
//     	var_dump('$options');var_dump($options);die();
    
    	return view('cp.web.welcome.index',compact('options','msg'));
    }
    
    public function login(Request $request)
    {
    	$options =[];
    	$msg = $request->has('msg')?$request->get('msg'):'';
    	return view('cp.web.auth.login',compact('options','msg'));
    }
    
    public function logout(Request $request)
    {
    	$request->session()->forget('cp_manage_auth');
    	$request->session()->forget('cp_manage_user');
    	\Log::info('logout');
    	return redirect()->to('/login');
    }
    
    public function get_session(Request $request)
    {
    	var_dump('manage_auth');
    	var_dump(session('manage_auth'));
    	var_dump('manage_user');
    	var_dump(session('manage_user'));
    }


}