<?php

namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

use Closure;

class MiddlewareCapataz
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle(Request $request, Closure $next)
    {
        switch(Auth::user()->user_tipe)
        {
            case('Capataz'):
                return $next($request);
                break;
            case('RRHH'):
                abort(403);
                break;
            case('Bodega'):
                abort(403);
                break;
            case('Admin'):
                abort(403);
                break;
            case('Gral'):
                abort(403);
            break;
        }
    }
}
