php - What is correct Route -


i created language switcher have problem when subpage. route:

route::post('/language', array(     'middleware' => 'languageswitcher',     'uses' => 'languagecontroller@index' )); 

works fine example:

http://localhost:8000/ http://localhost:8000/gallery 

but not for;

http://localhost:8000/gallery/bodnar 

then recaive

methodnotallowedhttpexception in routecollection.php line 218: 

if set:

route::post('/gallery/language', array(     'middleware' => 'languageswitcher',     'uses' => 'languagecontroller@index' )); 

works

http://localhost:8000/gallery/bodnar 

but not

http://localhost:8000/ http://localhost:8000/gallery 

what correct route::post universal?

my languageswitcher.php

namespace app\http\middleware;  use closure;  use app; use lang; use illuminate\support\facades\session; use illuminate\support\facades\config;  class languageswitcher {      /**      * handle incoming request.      *      * @param  \illuminate\http\request  $request      * @param  \closure  $next      * @return mixed      */     public function handle($request, closure $next) {         app::setlocale(session::has('locale') ? session::get('locale') : config::get('app.locale'));         return $next($request);     }  } 

i think understand need.

with language switcher, i'm going assume it's not absolute path?

perhaps use first example:

route::post('/language', array(     'middleware' => 'languageswitcher',     'uses' => 'languagecontroller@index' )); 

and when calling route use following in blade:

{{ url('language') }} 

this prevent directory issue.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -