언어 전환기를 만들었지 만 서브 페이지가있을 때 문제가 있습니다. 내 경로 : 예를 들어올바른 경로 Route
Route::post('/language', array(
'Middleware' => 'LanguageSwitcher',
'uses' => 'LanguageContr[email protected]'
));
작품 미세 :
http://localhost:8000/
http://localhost:8000/gallery
하지만하지 않는; 내가 설정 한 경우
http://localhost:8000/gallery/bodnar
는 내가
MethodNotAllowedHttpException in RouteCollection.php line 218:
recaive :
Route::post('/gallery/language', array(
'Middleware' => 'LanguageSwitcher',
'uses' => '[email protected]'
));
http://localhost:8000/gallery/bodnar
을위한 작품이 아닌
http://localhost:8000/
http://localhost:8000/gallery
올바른 Route :: post는 무엇이 보편적입니까?
내 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 an 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);
}
}
"유니버설"이란 무엇을 의미합니까? 모든 POST 요청 또는 언급 한 3 개의 요청 만 처리 할 수 있도록 하시겠습니까? (/,/갤러리,/갤러리/보드 나)? "/ gallery/language"가 "/ gallery/bodnar"와 어떻게 일치 할 수 있습니까? –
항상 라우팅된다는 의미입니다. 모든 POST. 서브 페이지/gallery/bodnar를 열었을 때 언어를 전환하려고 할 때나 내가 열 때/갤러리를 열 때. 어쩌면 내가 이런 식으로 사용해야합니다 : Route :: post ('/ {name?}/language'?하지만 작동하지 않는 및 문법이 올바른지 모르겠다. – Tomasz
나는 둘 다 Rout : ---' Route :: post ('/ {name}/Route :: post ('/ language ', array ( '미들웨어 '=>'LanguageSwitcher ', '은 '=>'LanguageController @ index '를 사용합니다) Route :: post ( '미들웨어'=> 'LanguageSwitcher', '=>'LanguageController @ index ' ));' – Tomasz