IsUser.php 775 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Http\Middleware;
  3. use Closure;
  4. use Auth;
  5. class IsUser
  6. {
  7. /**
  8. * Handle an incoming request.
  9. *
  10. * @param \Illuminate\Http\Request $request
  11. * @param \Closure $next
  12. *
  13. * @return mixed
  14. */
  15. public function handle( $request, Closure $next ) {
  16. if ( Auth::check() &&
  17. ( Auth::user()->user_type == 'customer' ||
  18. Auth::user()->user_type == 'seller' ||
  19. Auth::user()->user_type == 'delivery_boy' ||
  20. Auth::user()->user_type == 'salesman' ) )
  21. {
  22. return $next($request);
  23. }
  24. else
  25. {
  26. session([ 'link' => url()->current() ]);
  27. return redirect()->route('user.login');
  28. }
  29. }
  30. }