我正在制作一个检查锦标赛所有权的中间件。
所以在网址中,我有:
我需要在 $tournamentId 中获得“1”
在中间件中,我只有 $request 和 $closure 参数,所以我尝试了
$tournamentId = $request->get("tournaments");
正如@Amir Bar 所说:
$tournamentId = $request->tournaments;
我检查了路线
php artisan route:list
我得到
GET|HEAD | tournaments/{tournaments} | tournaments.show | App\Http\Controllers\TournamentController@show | auth,roles,ownTournament |
DELETE | tournaments/{tournaments} | tournaments.destroy | App\Http\Controllers\TournamentController@destroy | auth,roles,ownTournament |
PATCH | tournaments/{tournaments} | | App\Http\Controllers\TournamentController@update | auth,roles,ownTournament |
PUT | tournaments/{tournaments} | tournaments.update | App\Http\Controllers\TournamentController@update | auth,roles,ownTournament |
GET|HEAD | tournaments/{tournaments}/edit | tournaments.edit | App\Http\Controllers\TournamentController@edit | auth,roles,ownTournament | | auth,roles,ownTournament |
但没有任何效果...
我的中间件:
class OwnTournament
{
/**
* Check the ownership of tournaments
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
dd($request->route());
return $next($request);
}
}
知道我该怎么做吗???