中间件'auth'在Laravel 5.8中不起作用

时间:2019-12-28 01:47:17

标签: php laravel middleware laravel-5.8

对不起,我是拉丁裔,我的英语不好。

我在{{apiUrl}}/product?$joinEager=[brand, attributes]&$sort[brand.name]=-1文件中使用auth中间人,但是当我尝试从没有登录用户Laravel抛出异常来访问UserController.phpuser/profile_picture路由时,我无法使用user/bio例外。

web.php:

The GET method is not supported for this route. Supported methods: POST.

UserController.php:

Route::get("/", function(){
   return view('welcome');
});

Route::get('home', 'HomeController@index')->name('home');

Route::get("admin/users/seller_register", "Auth\RegisterController@showSellerRegistrationForm")
   ->name("users.seller_register_form");
Route::post("admin/users/seller_register", "Auth\RegisterController@sellerRegister")
   ->name("users.seller_register");

Route::get("admin/users/modal_delete_form", "AdministratorController@modalDeleteForm");
Route::get("admin/users/modal_update_form", "AdministratorController@modalUpdateForm");
Route::get("admin/users/crud_content", "AdministratorController@crudContent");
Route::resource('admin/users', 'AdministratorController');

Route::get("user/profile/{e_mail}", "UserController@profile")->name("user.profile");
Route::post("user/profile_picture", "UserController@profilePicture")->name("user.profilePicture");
Route::post("user/bio", "UserController@bio")->name("user.bio");

Auth::routes(["verify" => true]);

2 个答案:

答案 0 :(得分:1)

只需更改这些路线

Route::post("user/profile_picture", "UserController@profilePicture")->name("user.profilePicture");
Route::post("user/bio", "UserController@bio")->name("user.bio");

要...

Route::get("user/profile_picture", "UserController@profilePicture")->name("user.profilePicture");
Route::get("user/bio", "UserController@bio")->name("user.bio");

完成。

答案 1 :(得分:1)

尝试使用get方法

Route::get("user/profile_picture","UserController@profilePicture")->name("user.profilePicture");

Route::get("user/bio", "UserController@bio")->name("user.bio");