Localization.php 546 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App\Http\Middleware;
  3. use Closure;
  4. use Illuminate\Http\Request;
  5. use Illuminate\Support\Facades\App;
  6. use Illuminate\Support\Facades\Session;
  7. class Localization
  8. {
  9. /**
  10. * Handle an incoming request.
  11. *
  12. * @param \Illuminate\Http\Request $request
  13. * @param \Closure $next
  14. * @return mixed
  15. */
  16. public function handle(Request $request, Closure $next)
  17. {
  18. if (Session::has('locale')) {
  19. App::setLocale(Session::get('locale'));
  20. }
  21. return $next($request);
  22. }
  23. }