Laravel缺少路线问题

时间:2016-05-16 09:35:43

标签: php laravel routes laravel-5.2

我的Laravel路线有问题。 如果我调用以下网址:http://laravel/market它工作正常,但我的网站有不同的语言,所以我使用LaravelLocalization包,当我调用http://laravel/en/market时出现错误:

  

路线[market.offers.show]未定义。

我用过:

  

php artisan route:list

查看索引路由,这是它的快捷方式:

    | GET|HEAD                       | market/offers                                                                    | market.offers.index                    | App\Http\Controllers\Front\OffersController@index
    | POST                           | market/offers                                                                    | market.offers.store                    | App\Http\Controllers\Front\OffersController@store
    | GET|HEAD                       | market/offers/bid/{id}                                                           | market.offers.bid                      | App\Http\Controllers\Front\OffersController@bid
    | GET|HEAD                       | market/offers/create                                                             | market.offers.create                   | App\Http\Controllers\Front\OffersController@create
    | GET|HEAD                       | market/offers/history                                                            | market.offers.history                  | App\Http\Controllers\Front\OffersController@history
    | POST                           | market/offers/store/bid                                                          | market.offers.store.bid                | App\Http\Controllers\Front\OffersController@storebid
    | DELETE                         | market/offers/{offers}                                                           | market.offers.destroy                  | App\Http\Controllers\Front\OffersController@destroy
    | GET|HEAD                       | market/offers/{offers}                                                           | market.offers.show                     | App\Http\Controllers\Front\OffersController@show
    | PUT|PATCH                      | market/offers/{offers}                                                           | market.offers.update                   | App\Http\Controllers\Front\OffersController@update
    | GET|HEAD                       | market/offers/{offers}/edit                                                      | market.offers.edit                     | App\Http\Controllers\Front\OffersController@edit

在其他页面上,我收到Route [market.offers.create]

的相同错误

为什么?我该如何解决?

1 个答案:

答案 0 :(得分:0)

在您的路线中,您应该为该语言添加通配符,例如它看起来像/laravel/{lang}/market

然后在你的控制器中你处理如果lang为null或不设置默认语言