如何在Laravel中制作不同的路线名称?

时间:2016-10-17 13:46:39

标签: laravel laravel-5 laravel-5.3

我在不同的目录中有两个相同的控制器。

路由适用于:

Route::resource('dashboard/statistic', 'Admin\StatisticController');
Route::resource('statistic', 'StatisticController');

When I run php artisan route:list

我知道,这些路线的路线名称与:statistic

相同
statistic.index
statistic.destroy
statistic.edit

我怎样才能做到这一点?

3 个答案:

答案 0 :(得分:0)

您可以明确地创建每个路径( Route::get('dashboard/statistic', ['as' => 'dashboard-statistic.index', 'uses' => 'Admin\StatisticController@index']); Route::delete('dashboard/statistic', ['as' => 'dashboard-statistic.destroy', 'uses' => 'Admin\StatisticController@destroy']); Route::put('dashboard/statistic', ['as' => 'dashboard-statistic.edit', 'uses' => 'Admin\StatisticController@edit']); ),例如

{{1}}

答案 1 :(得分:-1)

也许

  Route::resource('dashboard/statistic', 'Admin\StatisticController',
                ['admin' => ['create', 'store', 'update', 'destroy']]);
    Route::resource('statistic', 'StatisticController');

希望这可以解决您的问题

答案 2 :(得分:-1)

也许这可以解决问题

Route::group(['prefix' => 'dashboard', 'as' => 'dashboard.'], function() {
    Route::resource('statistic', 'Admin\StatisticController');
});

将返回名称,例如:

  

dashboard.statistic.store