Support the ongoing development of Laravel.io →
Security Architecture
Last updated 2 years ago.
0

There is no one who has had this problem?

0

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.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

lovePizza lovepizza Joined 13 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.