Laravel 8:如何修复 ParseError 语法错误,意外的“;”
Laravel 8: How to fix ParseError syntax error, unexpected ';'
我知道这个问题可能听起来很愚蠢,但我正在使用 Laravel,并且我想 return 为我的一条位于组路线内的路线发出警告消息:
Route::middleware('auth')->group(function(){
Route::get('profile', [App\Http\Controllers\ProfileController::class, 'index'])->name('profile'){
alert()->success('welcome','message')->persistent('Ok');
}
Route::get('profile/twofactor', [App\Http\Controllers\ProfileController::class, 'manageTwoFactor'])->name('profile.2fa.manage');
Route::post('profile/twofactor', [App\Http\Controllers\ProfileController::class, 'postManageTwoFactor']);
});
正如您在路线 profile
中看到的那样,我已经设置了这条消息,但我收到了 ParseError syntax error, unexpected ';'
。
不幸的是,我不知道如何以正确的方式做到这一点。
所以如果你知道,请帮助我。
谢谢!
检查那一行:
Route::get('profile', [App\Http\Controllers\ProfileController::class, 'index'])->name('profile'){
alert()->success('welcome','message')->persistent('Ok');
}
你在 alert()...
周围用花括号,那是错误的。
您应该将其更改为:
Route::get('profile', [App\Http\Controllers\ProfileController::class, 'index'])->name('profile');
并将alert()->success('welcome','message')->persistent('Ok');
移动到ProfileController的索引方法class。
我知道这个问题可能听起来很愚蠢,但我正在使用 Laravel,并且我想 return 为我的一条位于组路线内的路线发出警告消息:
Route::middleware('auth')->group(function(){
Route::get('profile', [App\Http\Controllers\ProfileController::class, 'index'])->name('profile'){
alert()->success('welcome','message')->persistent('Ok');
}
Route::get('profile/twofactor', [App\Http\Controllers\ProfileController::class, 'manageTwoFactor'])->name('profile.2fa.manage');
Route::post('profile/twofactor', [App\Http\Controllers\ProfileController::class, 'postManageTwoFactor']);
});
正如您在路线 profile
中看到的那样,我已经设置了这条消息,但我收到了 ParseError syntax error, unexpected ';'
。
不幸的是,我不知道如何以正确的方式做到这一点。
所以如果你知道,请帮助我。
谢谢!
检查那一行:
Route::get('profile', [App\Http\Controllers\ProfileController::class, 'index'])->name('profile'){
alert()->success('welcome','message')->persistent('Ok');
}
你在 alert()...
周围用花括号,那是错误的。
您应该将其更改为:
Route::get('profile', [App\Http\Controllers\ProfileController::class, 'index'])->name('profile');
并将alert()->success('welcome','message')->persistent('Ok');
移动到ProfileController的索引方法class。