Advertisement
julong

Simple Method way to create button switch on lang#laravel

Jun 20th, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. /**
  2. * EAKKASIT TUNSAKOOL
  3. */
  4. Simple Method way to create button switch on language
  5. layout.blade.php
  6. //////////////////
  7. <li>{{ HTML::link('/th','th',array('id'=>'thailand','class'=>'thai')) }}</li>
  8. <li>{{ HTML::link('/en','en',array('id'=>'english')) }}</li>
  9.  
  10. Routes.php
  11. //////////////////
  12. Route::get('/th',array('uses'=>'authorsController@locate'));
  13. Route::get('/en',array('uses'=>'authorsController@locate_en'));
  14.  
  15. Controller
  16. //////////////////
  17. public function locate(){
  18. Session::put('language','th');
  19. App::setLocale('th');
  20. $view = View::make('layouts.default');
  21.  
  22. return $view;
  23. }
  24. public function locate_en(){
  25. Session::put('language','en');
  26. App::setLocale('en');
  27. $view = View::make('layouts.default');
  28.  
  29. return $view;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement