2016-05-16 113 views
0

我的Laravel路線有問題。 如果我撥打以下網址:http://laravel/market它工作正常,但我的網站有不同的語言,所以我使用LaravelLocalization包,當我打電話http://laravel/en/market談到一個錯誤:Laravel缺少路線問題

Route [market.offers.show] not defined.

我已經使用:

php artisan route:list

看到索引的路線,這裏是它的一個捷徑:

| GET|HEAD      | market/offers                 | market.offers.index     | App\Http\Controllers\Front\[email protected] 
    | POST       | market/offers                 | market.offers.store     | App\Http\Controllers\Front\[email protected] 
    | GET|HEAD      | market/offers/bid/{id}               | market.offers.bid      | App\Http\Controllers\Front\[email protected] 
    | GET|HEAD      | market/offers/create                | market.offers.create     | App\Http\Controllers\Front\[email protected] 
    | GET|HEAD      | market/offers/history               | market.offers.history     | App\Http\Controllers\Front\[email protected] 
    | POST       | market/offers/store/bid               | market.offers.store.bid    | App\Http\Controllers\Front\[email protected] 
    | DELETE       | market/offers/{offers}               | market.offers.destroy     | App\Http\Controllers\Front\[email protected] 
    | GET|HEAD      | market/offers/{offers}               | market.offers.show      | App\Http\Controllers\Front\[email protected] 
    | PUT|PATCH      | market/offers/{offers}               | market.offers.update     | App\Http\Controllers\Front\[email protected] 
    | GET|HEAD      | market/offers/{offers}/edit              | market.offers.edit      | App\Http\Controllers\Front\[email protected] 
上的其他網頁

我得到同樣的錯誤˚F或路線[market.offers.create]

這是爲什麼?我該如何解決這個問題?

回答

0

在你的路線,你應該增加對例如語言通配符它看起來像/laravel/{lang}/market

,然後在你的控制器,你處理,如果郎爲空或不設置默認語言

+0

我已經做了一個前綴:Route :: group(['prefix'=> LaravelLocalization :: setLocale()],function(){});裏面都是路線 –