0

在 web.php 路由文件中,我已经定义了路由组中的所有路由,但其中一些不起作用并显示空白页面,但在没有前缀的路由组之外定义时显示页面。

Route::group(['middleware' => 'auth', 'prefix' => 'admin'], function () {
    Route::get('/home', 'HomeController@index')->name('home');

    Route::resource('/category', 'CategoryController')->except(['destroy']);
    Route::get('/category/delete/{category}', 'CategoryController@destroy')->name('category.delete');

    Route::resource('/post', 'PostController')->except(['destroy']);
    Route::get('/post/delete/{post}', 'PostController@destroy')->name('post.delete');

    Route::get('/post/{post}/restore', 'PostController@restore')->name('post.restore');
    Route::get('/post/{post}/forceDelete', 'PostController@forceDelete')->name('post.forceDelete');
    Route::resource('/tag', 'TagController')->except(['destroy']);
    Route::get('/tag/{tag}/delete', 'TagController@destroy')->name('tag.destroy');

    Route::resource('user', 'UserController')->except(['destroy']);
    Route::get('/user/{user}/delete', 'UserController@destroy')->name('user.delete');
    Route::get('user/{user}/admin', 'UserController@makeAdmin')->name('user.admin')->middleware('admin');
    Route::get('/user/{user}/makeUser', 'UserController@makeUser')->name('user.user');
    Route::get('user/profile', 'ProfileController@index')->name('user.profile');
    Route::post('user/profile/update', 'ProfileController@update')->name('user.profile.update');
});
4

1 回答 1

0

您的路线相互冲突,生成Route::resource的路线与您自己定义的路线造成冲突enter code here

这里可能有问题

Route::get('/user/{user}/delete', 'UserController@destroy')->name('user.delete');
Route::get('user/profile', 'ProfileController@index')->name('user.profile');

'profile'可能作为参数用户传递,抛出一个空白页。

于 2019-05-06T06:30:12.287 回答