【发布时间】:2019-04-30 07:25:56
【问题描述】:
我有一些按前缀分组的路线,如下所示。但如果没有 URL 中的 {lang},它就无法工作。没有 {lang} 的 URL 将收到 404 错误。谁能猜出问题出在哪里?
路线
Route::group(['namespace' => 'Site', 'prefix' => '{lang?}',
'where' => array('lang' => 'en|fa')], function () {
if (\Request::segment(1) !== 'panel' || \Request::segment(1) !== 'login') {
$locale = \Request::segment(1);
if (in_array($locale, ['fa', 'en'])) Illuminate\Support\Facades\App::setLocale($locale);
}
Route::get('/', 'HomeController@index')->name('home');
Route::get('/about', 'AboutController@index')->name('about');
Route::get('/portfolio', 'PortfolioController@index');
Route::get('/portfolio/{category_id}/cat', 'PortfolioController@indexWithCategory');
Route::get('/portfolio/loadmore/{category_id}/cat', 'PortfolioController@loadmore');
Route::get('/portfolio/loadmore', 'PortfolioController@loadmore');
Route::get('/portfolio/{id}/{title}', 'PortfolioController@show');
Route::get('/articles', 'ArticleController@index');
Route::get('/articles/{id}/', 'ArticleController@article_show');
Route::get('/articles/{id}/{title}', 'ArticleController@article_show');
Route::get('/blogs', 'ArticleController@blogs');
Route::get('/blogs/{id}', 'ArticleController@show');
Route::get('/blogs/{id}/{title}', 'ArticleController@show');
Route::get('/faq', 'ArticleController@faq');
Route::get('/contacts', 'ContactsController@index');
});
【问题讨论】:
-
附言。 HomeController 有效!