我正在使用Laravel 5.6,使用默认的make:auth机制。
在routes / web.php中,我想添加一个语言中间件如下: -
Route::prefix('{lang}')->group(function () {
Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
});
现在我想在刀片中应用它: -
<a href="{{ route('password.request') }}">
但是调试器只是说: -
Missing required parameters for [Route: password.request] [URI: {lang}/password/reset].
我相信刀片不能从路线上获得{lang}。如何实现?
答案 0 :(得分:0)
试试这个
<a href="{{ url('en') }}/password/reset">
答案 1 :(得分:0)
当您在路线中传递前缀时,这意味着它将包含在路线中,所以当您说
时$(document).ready(function() {
$("input:radio").change(function() {
if($("#business").prop('checked') == true) {
$(".BusinessForm").show();
$(".TechnicalForm").hide();
$(".LoginForm").hide();
}else if($("#technical").prop('checked') == true) {
$(".BusinessForm").hide();
$(".TechnicalForm").show();
$(".LoginForm").hide();
}else if($("#login").prop('checked') == true) {
$(".BusinessForm").hide();
$(".TechnicalForm").hide();
$(".LoginForm").show();
}
});
});
这意味着路线将是这样的&#34; http://yourwebsite.com/ {lang} / password / reset&#34; &#34; http://yourwebsite.com/ {郎} /富/栏&#34;
所以每当你传递任何属于该组的路径时,都需要有一个名为$ lang的变量,这样就可以初始化链接。
所以在你的情况下
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="radio-buttons">
<div class="group">
<label for="business">Business radio</label>
<input type="radio" name="radio" id="business" checked />
</div>
<div class="group">
<label for="technical">Business radio</label>
<input type="radio" name="radio" id="technical" />
</div>
<div class="group">
<label for="login">Business radio</label>
<input type="radio" name="radio" id="login" />
</div>
</div>
<div class="BusinessForm">
<p class="showBusinessForm">Business</p>
</div>
<div class="TechnicalForm" style="display: none;">
<p class="showTechnicalForm">Technical</p>
</div>
<div class="LoginForm" style="display: none;">
<p class="showLoginForm">login</p>
</div>
如果您希望add a middleware到特定路线或路线组,则会以这种方式传递
Route::prefix('{lang}')->group(function () {
Route::get('password/reset' .......
Route::get('foo/bar' .......
或
<a href="{{ route('password.request', ['lang' => 'en']) }}"> //you can change en to your preferred language.
如果您想创建另一种语言,可以查看以下链接: