This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I am working on a plugin for my company and cannot seem to wrap my head around the proper way to create my models and their relationships.
I am extending the Users plugin to include an employer model and a job model. How do I determine whether or not I am using a has or belong relationship?
For example, my users can potentially have/belong to many jobs. Each job should only have/belong to one employer. I have followed several tutorials (https://octobercms.com/support/article/ob-21) and am not able to come up with a solution.
Ideally, I would like to be able to manage all of this from the users plugin. So when I open a user, I have an Employment tab. I would like to place a partial inside this tab with a list of jobs. I should be able to create and delete jobs from this section. When I go to create a job, I would like a popup to open with the fields to create the job. One of the fields for the job form needs to be the employer, which I believe can be done with either a relation, recordfinder, or partial field type.
If I use the recordfinder field, it will open a list of employers, however, if the employer does not exist, I have no way to create it on the fly. To address this issue, I found another article on the OctoberCMS forum (https://octobercms.com/forum/post/recordfinder-and-ability-to-add-new-items). Unfortunately, adding this as described produces an error: 'The partial _manage.htm' cannot be found.
Alternatively, I have tried using a partial but I either get an error telling me the relation config behavior does not contain a definition (which, in fact, it does) or it displays the list partial for the jobs model.
Does anyone have any suggestions about how I can solve this problem? This seems like a complex or involved problem and I simply cannot figure it out.
Thanks in advance.
I am not sure if this will help butthis playlist got me really far:
https://www.youtube.com/watch?v=3SmnExVW0Ag&list=PLUBR53Dw-Ef-X-_A1KLy41r2QArCBy4rM
1-2 of 2