<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\utilisateur;
class LoginController extends Controller
{
    public function login(Request $request){

    	$user = utilisateur::whereMailAndPassword($request->UserName, sha1($request->Password))->count('id');
    	if($user>0){
    		$user = utilisateur::whereMailAndPassword($request->UserName, sha1($request->Password))->first();
    		$request->session()->put('Name', $user->name);
    		$request->session()->put('Password', $user->password);
    		$request->session()->put('Email', $user->mail);

    		return redirect(route('Products.index'));
    	}else{
    		return view('welcome');
    	}
    }
}
