I have
users
id
username
companies
id
areas
id
area_company
id
area_id
company_id
area_company_user
id
area_company_id
user_id
company_user
id
company_id
user_id
area_user
id
area_id
user_id
where
- one
user
has 0 to manyareas
AND onearea
can have 0 to manyusers
- one
area
can have 0 to manycompanies
AND onecompany
can have 0 to manyareas
- one
company
can have 0 to manyusers
AND oneuser
can have 0 to manycompanies
- one
area_company
can have 1 to manyusers
AND oneuser
can have 0 to manyarea_company
area_company_user
has attributes specific to that kind ofuser
Also, I'm structuring the routes in the following manner
/users
- all existing users/areas
- all existing areas/companies
- all existing companies/areas/{area}/companies
- all existing companies in a specific area/users/{user}/companies
- all existing companies from a specific user/companies/{company}/areas
- all existing areas the company is in/areas/{area}/companies/{company}/users
- all existing users from a company that exists in a specific area
For 1., 2. and 3. I'm creating controllers that follow the next pattern
AreaController
with methods index(), create(), store(), show(), edit(), update() and destroy()
GET /areas, index() method,
GET /areas/create, create() method,
POST /areas, store() method,
GET /areas/{area}, show() method,
GET /areas/{area}/edit, edit() method,
PUT/PATCH /areas/{area}, update() method,
DELETE /areas/{area}, destroy() method.
There's now basically two cases left from that route list
- Case 1: 4., 5. and 6.
- Case 2: 7.
My question is, should I create new controllers for each case since I'd like to perform various actions in each? If yes, that'd mean, respectively
- Case 1:
AreaCompanyController
,UserCompanyController
andCompanyAreaController
- Case 2:
AreaCompanyUserController
Note: this was a helpful answer but didn't exactly address my concern.