CheckoutMiddleware.php 739 B

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