Laravel 5 get route prefix in controller method

前端 未结 3 1836
花落未央
花落未央 2021-01-07 18:53

I am working in Laravel 5.0 app.

I have created route group like below,

 Route::group([\'prefix\' => \'expert\'], function () {

    Route::get(\'         


        
相关标签:
3条回答
  • 2021-01-07 19:03

    You can do this two way

    Type-hinting Request in method

     public function index(\Illuminate\Http\Request $request){
      dd($request->route()->getPrefix());
     }
    

    or

     public function index(){
      dd($this->getRouter()->getCurrentRoute()->getPrefix());
     }
    

    I hope this helps.

    0 讨论(0)
  • 2021-01-07 19:11

    Try this

    $request = Request();
    $request->route()->group;
    
    0 讨论(0)
  • 2021-01-07 19:21
    Request()->route()->getPrefix()
    
    0 讨论(0)
提交回复
热议问题