<?php

namespace App\Http\Middleware;

use Closure;
use Auth;

class payment
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure $next
     * @return mixed
     */
    function handle($request, Closure $next, $guard = null)
    {

        if (!empty(Auth::user()->is_role)) {
            if (Auth::check()) {
                $role = Auth::user()->is_role;
                switch ($role) {
                    case 'Administrator':
                        return $next($request);
                        break;
                    case 'in_shop':
                        return $next($request);
                        break;
                    case 'out_shop':
                        return $next($request);
                        break;
                    case 'coporator':
                        return $next($request);
                        break;
                    default:
                        return response()->view('errors.403', [], 403);
                        break;
                }
            }
        }
        return redirect()->guest('login');

    }
}