IsAdmin.php 555 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App\Http\Middleware;
  3. use Closure;
  4. use Auth;
  5. class IsAdmin
  6. {
  7. /**
  8. * Handle an incoming request.
  9. *
  10. * @param \Illuminate\Http\Request $request
  11. * @param \Closure $next
  12. * @return mixed
  13. */
  14. public function handle($request, Closure $next)
  15. {
  16. if (Auth::check() && (Auth::user()->user_type == 'salesman' || Auth::user()->user_type == 'admin' || Auth::user()->user_type == 'staff')) {
  17. return $next($request);
  18. }
  19. else{
  20. abort(404);
  21. }
  22. }
  23. }