I want to pretty-up my routes, ie, I have such entries:
// DataTable
Route::get('dt/reservations/{room_id]', 'DataTablesController@reservations')->where(['room_id', '[0-9]+']);
Route::get('dt/rooms/{area_id]', 'DataTablesController@rooms')->where(['area_id', '[0-9]+']);
Route::get('dt/departments', 'DataTablesController@departments');
Route::get('dt/addresses', 'DataTablesController@areas');
Route::get('dt/areas', 'DataTablesController@areas');
I would like to make it more understandable. I can add prefix what would give me:
// DataTable
Route::group(['prefix' => 'dt'], function () {
Route::get('reservations/{room_id]', 'DataTablesController@reservations')->where(['room_id', '[0-9]+']);
Route::get('rooms/{area_id]', 'DataTablesController@rooms')->where(['area_id', '[0-9]+']);
Route::get('departments', 'DataTablesController@departments');
Route::get('addresses', 'DataTablesController@areas');
Route::get('areas', 'DataTablesController@areas');
});
But can I somehow make the rest too? The route name and method name will always be the same. Is it possible to make something like:
// DataTable
Route::group(['prefix' => 'dt'], function () {
Controller => DataTablesController,
Methods => [
'reservations',
'rooms',
'departments',
'addresses',
'areas'
];
});