<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;

class CSDMiddleware
{
    public function handle(Request $request, Closure $next)
    {
        // if (Auth::guard('csd')->check() && Auth::guard('csd')->user()->user_type === 'C') {
        //     // dd('hello');
        //     return $next($request);
        // }

        // return Redirect::route('csd.login');
        if (!session()->has('csd_session.user_id')) {
        return redirect()->route('csd.login')->with('error', 'Please login first');
        }

        return $next($request);
    }
}
