具有参数格式的命名路由

时间:2015-07-07 01:04:39

标签: laravel laravel-5 laravel-routing

我已经研究过,并且无法找到如何正确执行此操作的示例。

我需要结合以下内容:

Route::get('self', ['as' => 'self', 'uses' => 'FrontendController@self']);

Route::get('self/{type}', function($type = 'type'){});

2 个答案:

答案 0 :(得分:0)

您可以使用组前缀来解决它。例如:

 Route::group(['prefix' => 'self'], function()
{
    Route::get('/','FrontendController@self');
    Route::get('{type}',function($type){
        return $type;
    });
});

答案 1 :(得分:0)

像这样定义您的路线

localhost/index.php/1.js

在控制器方法中,您可以使用参数

Route::get('self/{type?}', ['as' => 'uses' => 'FrontendController@self']);