1
我想漂亮向上我的路線,即,我有這樣的條目:如何使用相同的控制器對相似的Laravel路線進行分組?
// DataTable
Route::get('dt/reservations/{room_id]', '[email protected]')->where(['room_id', '[0-9]+']);
Route::get('dt/rooms/{area_id]', '[email protected]')->where(['area_id', '[0-9]+']);
Route::get('dt/departments', '[email protected]');
Route::get('dt/addresses', '[email protected]');
Route::get('dt/areas', '[email protected]');
我想使其更容易理解。我可以添加前綴什麼會給我:
// DataTable
Route::group(['prefix' => 'dt'], function() {
Route::get('reservations/{room_id]', '[email protected]')->where(['room_id', '[0-9]+']);
Route::get('rooms/{area_id]', '[email protected]')->where(['area_id', '[0-9]+']);
Route::get('departments', '[email protected]');
Route::get('addresses', '[email protected]');
Route::get('areas', '[email protected]');
});
但我可以以某種方式讓休息嗎?路由名稱和方法名稱將始終相同。 是否有可能作出這樣的:
// DataTable
Route::group(['prefix' => 'dt'], function() {
Controller => DataTablesController,
Methods => [
'reservations',
'rooms',
'departments',
'addresses',
'areas'
];
});
太糟糕了,我加標籤,如果這改變了:) – Peon
@DainisAbols當然會讓你知道:) –