<?php

namespace App\Http\Middleware;

use Closure;

class MerchantLogout
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $merchant = session('merchant');

        if ($merchant == null) {
            return redirect()->to('/merchant/login')->with('login-error', 'Login to Gain Access!');
        }
        
        return $next($request);
    }
}
