<?php

namespace App\Http\Controllers;
  
 
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Http\Request;
use Illuminate\Routing\Redirector;
use Illuminate\Database\Eloquent\Model;
use App\Models\Category_model;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
use Illuminate\Support\Facades\DB; 
use Illuminate\Pagination\Paginator;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\Session;

class Home extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
	
	function index()
	 {
	   return view('welcome');
	 
	 
	 }
	 
	 function checklogin(Request $request)
	 {
		$postdata = $request->input();

		$userid=$postdata["userID"];
		$password=$postdata["password"];
     //echo   $str="SELECT user_id FROM users WHERE user_id='".$userid."' and password='".$password."' ";

	  $usercount= DB::table("users")->where("user_id","=",$userid )->where("password","=", $password )->count() ;
  
		if($usercount  ==1)
		{

			
			session('userid', $userid);
			return view('Dashboard'); 

		}
		else
		{

			return view('index'); 

		}
		
	
	 
	 }




	 	 function dashboard()
	 {
	   return view('Dashboard'); 
	 
	 }
	 
	function homeindex()
	 {
	   return view('index'); 
	 }
	 
	 
	 function logout()
	 {  
	   return view('welcome'); 
	 }
	 
	
}
