# |
Jul 5th 2017, 17:11 |
savant |
@jeremyharris get me a :rubberduck: emoji |
# |
Jul 5th 2017, 16:47 |
jeremyharris |
np! :beers: |
# |
Jul 5th 2017, 16:46 |
pedroseco |
ok that’s a wrap for today :slightly_smiling_face: Thanks for the help! |
# |
Jul 5th 2017, 16:46 |
pedroseco |
i will try with the example I did since probably is the most common one. |
# |
Jul 5th 2017, 16:46 |
jeremyharris |
if you can articulate what it doesn’t say, create an issue and ping me and I can write it |
# |
Jul 5th 2017, 16:46 |
jeremyharris |
contributions or suggestions welcome |
# |
Jul 5th 2017, 16:46 |
pedroseco |
those auto magic associations get me confused sometimes |
# |
Jul 5th 2017, 16:45 |
jeremyharris |
yeah, cake 3 is smarter when it comes to BTM. Just pass the entities you want to link to each other, as they are |
# |
Jul 5th 2017, 16:45 |
pedroseco |
not too sure if the Book explains this part very well. It’s a litle bit confusing |
# |
Jul 5th 2017, 16:45 |
jeremyharris |
heh sweet! |
# |
Jul 5th 2017, 16:45 |
pedroseco |
lol |
# |
Jul 5th 2017, 16:45 |
pedroseco |
what a long day! |
# |
Jul 5th 2017, 16:45 |
pedroseco |
that’s it! ahah! thanks … was driving me crazy… |
# |
Jul 5th 2017, 16:43 |
jeremyharris |
in fact, you might just be able to change file_id to id on this line: https://gist.github.com/pedroseco/7f960a7399c0ce4aca3dc68051d7fdfa#file-gistfile1-txt-L4 |
# |
Jul 5th 2017, 16:43 |
jeremyharris |
the only thing you should need in _joinData is the extra column |
# |
Jul 5th 2017, 16:43 |
jeremyharris |
yeah let the join table figure out the keys itself |
# |
Jul 5th 2017, 16:42 |
pedroseco |
ok got it, let me chek |
# |
Jul 5th 2017, 16:42 |
pedroseco |
ah ok so probably I need to add the id of the foreign model and not the join table one |
# |
Jul 5th 2017, 16:42 |
jeremyharris |
ok that might be the problem. Let me update my array real quick |
# |
Jul 5th 2017, 16:41 |
pedroseco |
it will always be an existing file yes |
# |
Jul 5th 2017, 16:41 |
jeremyharris |
@pedroseco but that should be done automatically. the files.0 in that case is the File entity itself, not the join table. maybe it should just be id if that’s an existing File |
# |
Jul 5th 2017, 16:40 |
jarard01 |
sure |
# |
Jul 5th 2017, 16:40 |
jeremyharris |
jarard01 cool I’ll update my answer, if you can accept I’d appreciate it :slightly_smiling_face: |
# |
Jul 5th 2017, 16:39 |
pedroseco |
yes its the fk |
# |
Jul 5th 2017, 16:39 |
jeremyharris |
the join table fk? |
# |
Jul 5th 2017, 16:39 |
jarard01 |
thanks!!!! |
# |
Jul 5th 2017, 16:39 |
jarard01 |
jeremyharris, it was a sort condition I had on the query that was causing the issue |
# |
Jul 5th 2017, 16:39 |
jeremyharris |
what is files.0.file_id? |
# |
Jul 5th 2017, 16:39 |
pedroseco |
it adds the records, as expected, into posts_files table. |
# |
Jul 5th 2017, 16:38 |
pedroseco |
ok so this is the snippet im using to save Files into Posts when both are with a association belongsToMany: https://gist.github.com/pedroseco/7f960a7399c0ce4aca3dc68051d7fdfa |
# |
Jul 5th 2017, 16:38 |
jeremyharris |
I’m getting a little confused cause the way you’re saving. what’s the end goal here? just save new files and link them to posts, no? |
# |
Jul 5th 2017, 16:37 |
pedroseco |
so probably it’s not correct yet |
# |
Jul 5th 2017, 16:36 |
pedroseco |
and just manipulated the $this->request->data to contain the _joinData |
# |
Jul 5th 2017, 16:36 |
pedroseco |
hum yes but in the last test i ended up not using the newEntity() |
# |
Jul 5th 2017, 16:35 |
jeremyharris |
also, check the saveStrategy |
# |
Jul 5th 2017, 16:35 |
jeremyharris |
if the record already exists, include the id explicitly, and then it won’t just insert new ones |
# |
Jul 5th 2017, 16:34 |
pedroseco |
since altough it creates the records on the join table, it also creates empty records on the foreign model… arghhh |
# |
Jul 5th 2017, 16:34 |
pedroseco |
so probaly i can’t just add the arrays as _joinData |
# |
Jul 5th 2017, 16:34 |
pedroseco |
eheh |
# |
Jul 5th 2017, 16:33 |
jeremyharris |
@savant we need a :rubberduck: emoji :P |
# |
Jul 5th 2017, 16:33 |
pedroseco |
2many hours around the same problem gets this kind of result :| |