lofty's avatar
Level 1

More elegant way to work with many similar controllers.

Hello, I have the following scenario. I have got some different routes which all do basicly CRUD actions. These actions are pretty similar but there are still some differences between. At the moment I have for each Route resource a controller. It works but I do not think that this is the correct way. Is there a more dry way so I can do like one class where I can define all functions and call them specifc parameter of each Route. I am not sure if that is correct but I am sure there is a more elegant way than mine. Maybe someone can help me out.

0 likes
2 replies
rin4ik's avatar

you want kinda like this?

  Route::get('/upload', 'VideoUploadController@index');
    Route::post('/upload', 'VideoUploadController@store');
    Route::get('/videos', 'VideoController@index');
    Route::post('/videos', 'VideoController@store');
    Route::delete('/videos/{video}', 'VideoController@delete');
    Route::get('/videos/{video}/edit', 'VideoController@edit');
    Route::put('/videos/{video}', 'VideoController@update');
    Route::put('/channel/{channel}/edit', 'ChannelSettingsController@update');

Please or to participate in this conversation.