Advertisement
Guest User

Untitled

a guest
Jun 24th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. protected $languages = ['en', 'ar'];
  2.  
  3. public function handle($request, Closure $next)
  4. {
  5. Session::has('applocale') ? Session::get('applocale') : Session::set('applocale', 'en');
  6.  
  7. if (in_array(Session::get('applocale'), $this->languages)) {
  8. $lang = Session::get('applocale');
  9. Session::set('applocale', $lang);
  10. App::setLocale($lang);
  11. } else {
  12. Session::set('applocale', 'en');
  13. App::setLocale('en');
  14. }
  15.  
  16. return $next($request);
  17. }
  18.  
  19. Route::group(['middleware' => ['web', 'language']], function () {
  20. // app routes
  21. });
  22.  
  23. Route::group(['middleware' => ['web', 'language']], function () {
  24. Route::group(['prefix' => '{lang}'], function () {
  25. // app routes
  26. });
  27. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement