Log message #4202020

# At Username Text
# Sep 6th 2019, 10:18 neon1024 I did think this was odd `EmailaddressesTable` instead of `EmailAddressesTable`
# Sep 6th 2019, 10:16 jotpe gosh.
# Sep 6th 2019, 10:12 ndm @jotpe Listen to @spriz, he knows what's up... your table object is an "auto-table", an instance of `\Cake\ORM\Table` instead of a concrete extending class thereof. Check your spelling, namespaces, filenames, etc, for some reason your table class cannot be found.
# Sep 6th 2019, 10:07 david098 so you can do something like $jobs = $this->Jobs->Users->Emailaddresses->find('ownedBy', ['user' => 2])->first();
# Sep 6th 2019, 10:07 jotpe Wait, I'll check check for another Model...
# Sep 6th 2019, 10:06 david098 is there an association between emailaddresses and jobs?
# Sep 6th 2019, 10:05 jotpe Yes, but not working.
# Sep 6th 2019, 10:04 david098 i used different models :slightly_smiling_face:
# Sep 6th 2019, 10:04 david098 $query= $emailTable->find('ownedBy', ['user' => 2])->first();
# Sep 6th 2019, 10:02 jotpe Unknown finder method "ownedBy" :thinking_face:
# Sep 6th 2019, 10:00 david098 Testing had to add ->first() to my controller $query= $this->EmailTable->find('ownedBy', ['user' => 2])->first();
# Sep 6th 2019, 09:59 jotpe and this is working $emailTable->findByUserId($user->getIdentifier());
# Sep 6th 2019, 09:58 jotpe @spriz it's object(Cake\ORM\Table)
# Sep 6th 2019, 09:57 jotpe @david098 already changed this
# Sep 6th 2019, 09:57 javier.villanueva $this->User->EmailAddress->find()->where(['user_id' => $user->id])->first();
# Sep 6th 2019, 09:56 david098 dont call $options['user']->id
# Sep 6th 2019, 09:56 david098 $options['user'] is already the id of the user
# Sep 6th 2019, 09:56 jotpe @alexdd55976 In my Model a user can Has Many EmailAdresses. Since i need a function at some places in my code to get the most recent Emailaddress of the user and didn't want to the query everytime in a controller.
# Sep 6th 2019, 09:56 spriz is it Cake\Orm\Table or your actual Table instance?
# Sep 6th 2019, 09:55 spriz @jotpe what is output `debug($emailTable)`?
# Sep 6th 2019, 09:55 david098 testing your code showed me that $user->id is not valid in findOwnedBy
# Sep 6th 2019, 09:54 jotpe @neon1024 I removed the ->first() and tried to replace it with the example from here https://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#custom-finder-methods both didn't work. Seems that the method cannot be found on that table?!
# Sep 6th 2019, 09:51 alexdd55976 @jotpe except from your problem... i find the your `$emailTable->find('ownedBy)` somehow very disturbing. especially because its somehow generic (which would be fine) but then in a specific model... why not calling a model method directly with the user_id, which is available anyway? :thinking_face:
# Sep 6th 2019, 09:49 javier.villanueva and you dont need ->getIdentifier() in call
# Sep 6th 2019, 09:48 javier.villanueva +1
# Sep 6th 2019, 09:48 javier.villanueva yes
# Sep 6th 2019, 09:48 neon1024 Calling `first()` you’re executing, converting to ResultSet and popping the first Entity
# Sep 6th 2019, 09:48 neon1024 So that you can chain finders
# Sep 6th 2019, 09:48 neon1024 A custom finder should return a `Query` instance right?
# Sep 6th 2019, 09:47 neon1024 @jotpe You’re calling `->first()`
# Sep 6th 2019, 09:46 jotpe Cleared Cache, but didn't changed anything. $user is the user and $user->getIdentifier() is the userId. I changed this, but it didn't even get into the function...
# Sep 6th 2019, 09:45 alexdd55976 i upvoted your answer ;)
# Sep 6th 2019, 09:42 javier.villanueva $emailTable->find('ownedBy', ['user' => $user]);
# Sep 6th 2019, 09:42 javier.villanueva or
# Sep 6th 2019, 09:42 javier.villanueva $query->where(['user_id' => $user, 'status' => 'confirmed']
# Sep 6th 2019, 09:41 javier.villanueva user is the id?
# Sep 6th 2019, 09:41 david098 did you cleared the cache?
# Sep 6th 2019, 09:34 jotpe Anyone has a clue why the custom finder is not working? I sticked to https://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#custom-finder-methods
# Sep 6th 2019, 09:34 slackebot <jotpe>
# Sep 6th 2019, 09:31 david098 Thanks for pushing me in the right direction
# Sep 6th 2019, 09:31 david098 For the onces who have looked into my issue yesterday, i created a working solution; https://stackoverflow.com/questions/57807225/