php - TYPO3: How to implement a virtual attribute based on a relationship table?Get the solution ↓↓↓
My question is simpler to what the title suggests, it's the most succinct way I've managed to word it...
What I want to do is: My Project entity is linked to User through a MM table. At the same time, Users are linked to multiple Companies. In the
project-user-mm table, I've added a field called
user_company, which stores a reference to the User's Company through which they are involved with the Project.
I think that this reference to the Company belongs in the Project-User relationship table instead of to the Project table directly because the Project-Company relationship is implicit through the User. Am I correct?
What I want to achive is that at the higher level (Extbase), whenever I call
Project->getCompanies, it fetches all the companies: each company from each
project-user-mm table. I don't need any other method (e.g.
remove, ...), since it wouldn't make sense to use them, because the Companies are retrieved implicitly from the relationships with the Users.
What would be the most idiomatic way to do this with TYPO3?
- In the
ProjectModel: Besides the
getCompaniesmethod, do I need a
- In the
ProjectTCA: do I need a
companiescolumn? In the case that I do, what type should it be?
none? Or maybe another one? This is the trickiest part, I think
- In the database: do I just need to put the
user_companyfield in the
project-user-mmtable? Or do I also need to put a
companiesfield in the
Sorry for the extensive post but I wanted to be as clear as possible in my explanation. I would appreciate a lot the help since I cannot find any similar examples online. Thank you in advance!
People are also looking for solutions of the problem: object of class stdclass could not be converted to string
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.