更新时间:2022-01-18 21:24:00
使用Laravel路线,顺序很重要。具有动态段(如 files / {file}
或资源路由)的路由应始终在之后定义为静态的路径。否则,Laravel将将您的URL中的共享
部分解释为ID。
With Laravel routes, the order matters. Routes with dynamic segments like files/{file}
or resource routes should always be defined after the ones that are static. Otherwise Laravel will interpret the share
part in your URL as ID.
所以,你已经想出了自己您只需要更改路线的顺序:
So, as you've figured out yourself you simply need to change the order of your routes:
Route::put('/files/share', 'FileController@test');
Route::resource('/files', 'FileController');