<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use DB;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;


    public function getConfig()
    {
        $config     = DB::select("SELECT  * from tbl_config ");
        return $config;
    }
    public function getUser()
    {
        $user       = DB::select(" select * From tbl_user where is_active=1 and role='agent';");
        return $user;
    }

    public function isLogin()
    {
        $value = session('user');
        if( isset($value['is_login']))
        {
            if( $value['is_login'])
            {
                return "true";
            }else{
                return "false";
            }
        }else{
            return "false";
        }
        // return redirect('/agent/login');
    }
    public function isALogin()
    {
        $value = session('auser');

        if( isset($value['is_login']))
        {
            if( $value['is_login'])
            {
                return "true";
            }else{
                return "false";
            }
        }else{
            return "false";
        }
        // return redirect('/agent/login');
    }
    public function logoutAdmin()
    {
        session(['user' => null]);
        session(['auser' => null]);
        $info = session('info');
        return redirect ($info['url']);
    }
    public function logout()
    {
        session(['user' => null]);
        session(['auser' => null]);
        $info = session('info');
        return redirect ("/agt_");
    }
}
