Sven0188
3 weeks ago

Project Structure & Layout when Dealing with Different User Types etc.

Posted 3 weeks ago by Sven0188

Good day Everyone,

Please help me with my structure. I not sure if I am over complicating things here.

But let's assume the following:

  1. I have different user types i.e: "admin", "business", "business_client", "client".
  2. Each user type has different rights in terms of what they can see and do. For example, the "admin" user will have CRUD access/rights to every other user and models.
  3. "business" will only have access to its own data and all other users ("business_client") assigned to it.
  4. There are several "admin" routes/endpoints which only "admin" will have access to i.e: system configuration which no other user should have access to.

So for my Http\Controllers I have this Folder structure:

  • Controllers\Admin\
  • Controllers\Business
  • Controllers\BusinessClient
  • Controlllers\

My routes file looks like this:


//Business Users
Route::group(["prefix" => "/backend/business"], function() {
    Route::resource("backend_admin_communication", "Backend\Admin\CommunicationController");
    Route::resource("backend_business_owner", "Backend\OwnerController");
    Route::resource("backend_business_document", "Backend\DocumentController");
    Route::resource("backend_business_vehicle", "Backend\VehicleController");
});


//Admin User
Route::group(["prefix" => "/backend/admin"], function() {
    Route::resource("backend_admin_communication", "Backend\Admin\CommunicationController");
        Route::resource("backend_admin_owner", "Backend\OwnerController");
    Route::resource("backend_admin_user", "Backend\UserController");
    Route::resource("backend_admin_pricerange", "Backend\PriceRangeController");
    Route::resource("backend_admin_commissionrange", "Backend\CommissionRangeController");
    Route::resource("backend_admin_country", "Backend\CountryController");
    Route::resource("backend_admin_payment", "Backend\PaymentController");
    Route::resource("backend_admin_goal", "Backend\Admin\AdminGoalController")->only(["index", "update"]);
});


And then also my views are similarly structured:

  • views\backend
  • views\backend_admin
  • views\backend_business etc

But it feels to me too much duplication. I try to constantly remind me of the DRY principle. For instance, with Controllers, I will have a: CommunicationController , for "admin" and "business" user type.

Would love to hear how the Experts here would have approached this?

Thanks a million!

Please sign in or create an account to participate in this conversation.