<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class LoginController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        if (isset($_COOKIE['crs'])) {
            $usuario = json_decode($_COOKIE['crs']);
            $date = explode(" ", now());
            $data = $request->all();
            //$usuario->idDep=16;

            $enc = $usuario->encargado;
            $ima = $usuario->imagen;
            $dep = $usuario->departamento;
            $usu=json_decode($_COOKIE['crs']);
            return view('principalexpo', compact('enc', 'ima', 'dep','usu'));
        } else {
            header('Location: https://poa.zitacuaro.tecnm.mx/');
        }
    }


    public function logout()
    {
        setcookie("ttl", "", time() - 3600, "/", ".zitacuaro.tecnm.mx", 1);
        header('Location: https://poa.zitacuaro.tecnm.mx/');
    }
}
