我试试
$suffix = '.test';
Route::get('article/edit/{name?}'.$suffix, ['uses' => 'ArticleController@edit', 'as' => 'Edit']);
它运作良好。然后我添加了auth组,$ name总是以$ suffix返回(例如:$ name =' abc.test')
Route::group(['middleware' => 'auth'], function () {
global $suffix;
Route::get('article/edit/{name?}'.$suffix, ['uses' => 'ArticleController@edit', 'as' => 'Edit']);
});
但我希望它返回$ name =' abc&#39 ;; 我哪里错了?
答案 0 :(得分:0)
如果你做了什么?
Route::group(['middleware' => 'auth'], function () {
global $suffix = '.test';
Route::get('article/edit/{name?}'.$suffix, [
'uses' => 'ArticleController@edit',
'as' => 'Edit'
])->where('name', '/[^a-zA-Z0-9_\.-]/');
});