lovePizza said:
Is a good practice use different controller for the user control panel and the admin control panel even if the controller works on the same data and do the same action? Something like this:
Route::group(array('domain' => 'mysite.com'), function() {
Route::group(array('before' => 'auth'), function() { Route::get('profile', 'UserController@edit'); // UserController });
});
Route::group(array('domain' => 'admin.mysite.com'), function() {
Route::group(array('before' => 'auth'), function() { Route::resource('user', 'AdminUserController'); // AdminUserController });
});
If you would be using the same functions in both admin and siteroot, then what is the point of the admin interface at all?
Generally, I would separate it into the root mainly fetching data from the server, and admin both fetching and posting. How you decide to structure it is largely up to you. Some people decide to structure it with one controller per model, while others use one controller per function group. If you have functions that can only be used in admin and not in root view, then by all means, place that in a separate controller.
What is most important is that you minimise (or best case even eliminate) code duplication, and that the structure is clear.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community