Log message #4124720

# At Username Text
# Mar 13th, 16:58 neon1024 Does that make sense? :slightly_smiling_face:
# Mar 13th, 16:58 neon1024 As it is associated to the two tables to normalize that many to many database relationship
# Mar 13th, 16:57 neon1024 Which is why you can see the `CoursesMembershipsTable` from the book, has two `belongsTo` associations in it
# Mar 13th, 16:57 neon1024 This is what the book page is saying
# Mar 13th, 16:57 neon1024 So when you inverse that association, you also get `ApplicantsDegrees belongsTo Applicants` in your ApplicantsDegreesTable
# Mar 13th, 16:56 neon1024 Then change the association from `belongsToMany` to `Applicants hasMany ApplicantsDegrees`
# Mar 13th, 16:56 neon1024 So you want to actually create a join table class, ApplicantsDegreesTable
# Mar 13th, 16:56 neon1024 That will allow Cake to automatically understand the join, but you need more control!
# Mar 13th, 16:56 neon1024 However
# Mar 13th, 16:55 neon1024 Which is why you’ve declared a ‘joinTable’ in your association configuration in your Table class
# Mar 13th, 16:55 neon1024 So you have to put a join table in the middle
# Mar 13th, 16:55 neon1024 Instead of a belongsToMany
# Mar 13th, 16:55 neon1024 Then you have two belongsTo and hasMany
# Mar 13th, 16:55 neon1024 `[ ] >- [ ] -< [ ]`
# Mar 13th, 16:54 neon1024 So you put a table in the middle
# Mar 13th, 16:54 neon1024 You need to convert `[ ] >-< [ ]` style ERD into a One to Many, on either side to normalise the Many To Many
# Mar 13th, 16:54 neon1024 You know in a database, what normalisation is right?
# Mar 13th, 16:53 willem what association should i make and where?
# Mar 13th, 16:53 neon1024 You know that in a database you cannot have a Many to Many relationship right?
# Mar 13th, 16:53 willem I read that piece from the docs 100 time, just do not understand it, there is a ApplicantsDe
# Mar 13th, 16:52 neon1024 https://book.cakephp.org/3.0/en/orm/associations.html#using-the-through-option
# Mar 13th, 16:52 neon1024 Just copying and pasting random code from Slack into your project won’t magically make stuff work
# Mar 13th, 16:52 neon1024 You must create the associations
# Mar 13th, 16:52 neon1024 Well of course
# Mar 13th, 16:51 slackebot with ApplicantsDegrees_
# Mar 13th, 16:51 willem if i try your code ``` $test = $this->ApplicantsTable ->find() ->where( [ 'Applicants.id' => '00000000-0000-0000-0000-100000000001', ] ) ->contain( [ 'ApplicantsDegrees' => ['Degrees'], ]) ->first(); ``` i get an error _InvalidArgumentException: Applicants is not associated
# Mar 13th, 16:51 willem not sure what you mean by this ```Your `applicants_degrees` join table has more than foreign keys in, so should really have a table instance```
# Mar 13th, 16:47 neon1024 Making your join more verbose `$this->Applicants->find()->contain(['ApplicantsDegrees' => ['Degrees']])`
# Mar 13th, 16:47 neon1024 Your `applicants_degrees` join table has more than foreign keys in, so should really have a table instance
# Mar 13th, 16:46 neon1024 As you want to store data in the join
# Mar 13th, 16:46 neon1024 @willem They’re right that you need a join table instance
# Mar 13th, 16:42 willem could anybody with good knowledge of join tables please help me with this: https://discourse.cakephp.org/t/trying-to-get-additional-data-using-belongstomany-with-multiple-tables/3699 The find does not show the data from other tables using the find. Maybe it should be called differently but i just cannot get this working.
# Mar 13th, 16:35 xinobi dereuromark however it is not possible with the current database and I'm not sure how deep I need to go to fix this
# Mar 13th, 16:33 dereuromark then there is no problem :slightly_smiling_face:
# Mar 13th, 16:33 xinobi dereuromark exactly
# Mar 13th, 16:32 dereuromark there should only be one table, but different roles and additional data etc linked to this.
# Mar 13th, 16:31 dereuromark xinobi: what you want is usually not a good design.
# Mar 13th, 16:30 jeremyharris e.g., override FormAuthenticate::authenticate to iterate through your tables, setting the config userModel and just reusing the default _findUser method
# Mar 13th, 16:29 jeremyharris not the component, but the Authenticate object. that’s where you want to look. Look at FormAuthenticate (or whatever base authenticator you’re using) and extend that to fit your needs
# Mar 13th, 16:28 xinobi jeremyharris I need to pass an array of models... but the base auth component only supports a string so I guess I would need to implement my own component yes
# Mar 13th, 16:26 jeremyharris xinobi you can create additional authenticators that extend the authenticator you’re using (e.g. Form) and add it to your authenticate array, with configuration per-authenticator. For example, create a CustomAuthenticate extends FormAuthenticate, then configure it in the auth component with the different userModel