2016-09-09 7 views
0

にミドルウェアのhandleメソッドにURLパターンを取得し、私が定義したルートは、(例えば)である:http://localhost:8000/entities/5/queriesroutes.phpのではlaravel

public function handle($request, Closure $next, $guard = null) { 
    echo $request->path(); //returns entities/5/queries 
    return $next($request); 
} 

今、私が必要ミドルウェアのそのURLパターンにアクセスします。 すなわちエンティティ/ {id} /クエリです。 URLパターンを返すメソッドはありますか?

答えて

1

$requestオブジェクト内のルートを使用してこれを行うことができます。このよう

$request->route()->uri();

これはあなたのケースでentities/{id}/queriesを返します。

関連する問題