2016-11-15 142 views
0

Route::controller在Laravel 5.3过时, 现在,我想我的设计路线,但我不知道我能做到这一点没有Route::controller,因为我不想定义Route::get为每个路由和我想要处理我的控制器中的参数。设计路线::控制器

例如,这些都是我的路线:

http://domain.com/images/10/pic.jpg (in this route I need 10 as $file_id and pic.jpg as $file_name) 
http://domain.com/images/crop/200x100/10/pic.jpg (in this route I need crop as $action, 200x100 as $size, 10 as $file_id and pic.jpg as $file_name) 

我怎么能做到这一点不Route::controller

+0

你可以使用'路线::资源()' –

+0

@RimonKhan感谢,但资源创建CRUD方法,我不不需要这些方法,我想用我自己的方法 – MajAfy

回答

0

目前,创建新路线的唯一方法是使用资源控制器(Route::resource())或通过Route::get,Route::post等定义自己的路线。

没有更快和目前没有废弃的方法。无论如何,Resource::controller()函数可能被提取到另一个包中,正如Taylor Otwell在他的upgrade guide中所述。

0

当Route :: controller没有明显的原因被抛弃时,我面临着和你一样的困境。

这就是为什么我写了一个名为AdvancedRoute的类,它可以作为替代品的下降。

它可以通过简单地用AdvancedRoute替换路线::控制器::控制器这样使用:

AdvancedRoute ::控制器( '客户', 'CustomerController');

的全部信息如何安装和使用找到在GitHub库:

https://github.com/lesichkovm/laravel-advanced-route