Route::getCurrentRoute()->getPath();因为Route对象属于请求阶段,而框架将其关联到了 Request 对象上,所以也可以下面这样链式调用:Request::route()->getName();在 Laravel 5.1 内这样写:useIlluminate\Support\Facades\Route;$currentPath= Route::getFacadeRoot()->current()->uri();Laravel 5.2 使用...
)->route()->getName()或者:②、use Illuminate\Support\Facades\Route;Route::currentRouteName();
Route::getCurrentRoute()->getPath(); 因为Route对象属于请求阶段,而框架将其关联到了 Request 对象上,所以也可以下面这样链式调用: Request::route()->getName(); 在Laravel 5.1 内这样写: use Illuminate\Support\Facades\Route;$currentPath= Route::getFacadeRoot()->current()->uri(); Laravel 5.2 使用...
Route::getCurrentRoute()->getPath(); 因为Route对象属于请求阶段,而框架将其关联到了 Request 对象上,所以也可以下面这样链式调用: Request::route()->getName(); 在Laravel 5.1 内这样写: use Illuminate\Support\Facades\Route; $currentPath= Route::getFacadeRoot()->current()->uri(); Laravel 5....
Route::get('user/{name}', function($name) { // }) ->where('name', '[A-Za-z]+'); Route::get('user/{id}', function($id) { // }) ->where('id', '[0-9]+'); 路由过滤器 路由过滤器提供了一种限制访问指定路由的简单的方法,这在您需要为您的站点创建需要认证区域的时候非常有用...
Route::get('user/{id}/{name}',function($id,$name) { // }) ->where(array('id'=>'[0-9]+','name'=>'[a-z]+')) 定义全局模式 如果希望在全局范围用指定正则表达式限定路由参数,可以使用pattern方法: Route::pattern('id','[0-9]+'); ...
Route::get('user/{id}', function($id) { return 'User '.$id; }); 可选路由参数 代码如下: Route::get('user/{name?}', function($name = null) { return $name; }); 带有默认值的可选路由参数 代码如下: Route::get('user/{name?}', function($name = 'John') ...
currentPath= Route::getFacadeRoot()->current()->uri();到了5.2版本,就是题主的写法:Route::currentRouteName();5.3版本到5.8版本,更加灵活了:uri = $request->path();使用 Request 对象的方法就可以返回。获取路由,路由名称,方法名:route = Route::current();name = Route::...
方法1 使用 sys 库 import sys sys._getframe().f_code.co_name 方法2 使用 inspect 库 ...
获取laravel 的路由 name,两种方式 use Illuminate\Support\Facades\Route; $route = Route::current(); $name = Route::currentRouteName(); $action = Route::currentRouteAction(); 二 自带函数 request()->route()->getName(); $request = app('request')->create('https://learnku.com/laravel/...