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 many areas
AND one area
can have 0 to many users
- one
area
can have 0 to many companies
AND one company
can have 0 to many areas
- one
company
can have 0 to many users
AND one user
can have 0 to many companies
- one
area_company
can have 1 to many users
AND one user
can have 0 to many area_company
area_company_user
has attributes specific to that kind of user
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
and CompanyAreaController
- Case 2:
AreaCompanyUserController
Note: this was a helpful answer but didn't exactly address my concern.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…