Best practice regarding controllers for a resource that can have different parent classes

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Best practice regarding controllers for a resource that can have different parent classes



I'm currently trying to refactor some controller code and I came accross some code that I'm not sure how to implement in a correct way.



My application has users and companies, and both can have projects.
The current situation is that we have 2 urls:



Those will route to the same controller which will handle the request differently based on if a company_id exists or not. This is not very clean in my opinion so I have been thinking about a better way to do this.



So far, I think the best way is to split them up in seperate controllers, like:



But since the only difference between a user project and a company project is pretty much that one has a 'user_id' and the other has a 'company_id', it feels like that will not be very DRY as I'll be writing a lot of duplicate code.



The current solution probably isn't as much of a problem, but I want to do this the correct way, so was hoping that someone over here would have a suggestion on how to handle this.



Thanks in advance!









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

4tvkwksk91
w6 oq8AqRkKBff6co3zGJV5YIT XGJ eTHe

Popular posts from this blog

Makefile test if variable is not empty

Visual Studio Code: How to configure includePath for better IntelliSense results

Will Oldham