# |
Apr 9th 2019, 07:24 |
spriz |
:,) |
# |
Apr 9th 2019, 07:24 |
neon1024 |
I will qualify it that I’ve just arrived at work and haven’t had a coffee yet! :P |
# |
Apr 9th 2019, 07:24 |
spriz |
Yeah, I think I will :slightly_smiling_face: |
# |
Apr 9th 2019, 07:24 |
spriz |
I’ll explore youre idea and check pros and cons though |
# |
Apr 9th 2019, 07:24 |
neon1024 |
Give it a go in a branch perhaps and bake some stuff, see how you like it |
# |
Apr 9th 2019, 07:23 |
spriz |
Just `Products BelongsToMany Products through RelatedProducts` - same same though |
# |
Apr 9th 2019, 07:23 |
spriz |
That was my original idea |
# |
Apr 9th 2019, 07:23 |
neon1024 |
..and the store the association type in the join table? :man-shrugging: |
# |
Apr 9th 2019, 07:23 |
neon1024 |
Perhaps Products hasAndBelongsToMany Products Through AssociatedProducts |
# |
Apr 9th 2019, 07:22 |
neon1024 |
Or maybe I’m wrong. Perhaps you just want a hasAndBelongsToMany Through |
# |
Apr 9th 2019, 07:22 |
neon1024 |
Perhaps I explained it badly! :P |
# |
Apr 9th 2019, 07:22 |
neon1024 |
That’s the many-to-many part, so you can have the products to choose from :slightly_smiling_face: |
# |
Apr 9th 2019, 07:21 |
spriz |
thanks though! |
# |
Apr 9th 2019, 07:21 |
spriz |
I have to draw it to understand I think :P |
# |
Apr 9th 2019, 07:21 |
neon1024 |
They would be |
# |
Apr 9th 2019, 07:21 |
neon1024 |
That would be my approach anyway :slightly_smiling_face: |
# |
Apr 9th 2019, 07:21 |
spriz |
but those AssociatedProduct need to be other `Product`entities |
# |
Apr 9th 2019, 07:21 |
neon1024 |
Then you could customise the property name depending on the AssociatedProductTypes.name |
# |
Apr 9th 2019, 07:21 |
neon1024 |
So then I’d have a product, and a nice ’associated_products` entity property with an array of products |
# |
Apr 9th 2019, 07:20 |
neon1024 |
`$this->Products->find()->contain(['AssociatedProducts' => function (Query $q) { return $q->where(['AssociatedProducts.association_type_id' => 1]); } ]);` |
# |
Apr 9th 2019, 07:20 |
spriz |
Ah I see |
# |
Apr 9th 2019, 07:19 |
neon1024 |
Product hasMany AssociatedProduct |
# |
Apr 9th 2019, 07:19 |
neon1024 |
AssociatedProduct belongsTo Product |
# |
Apr 9th 2019, 07:19 |
neon1024 |
Many rows |
# |
Apr 9th 2019, 07:19 |
neon1024 |
As the association would be to the product |
# |
Apr 9th 2019, 07:19 |
spriz |
then how would that link 2 products :thinking_face: ? |
# |
Apr 9th 2019, 07:18 |
neon1024 |
It would only have product_id |
# |
Apr 9th 2019, 07:18 |
neon1024 |
It would not, no. |
# |
Apr 9th 2019, 07:18 |
neon1024 |
Then I could get any product, and get all it’s associations by type |
# |
Apr 9th 2019, 07:18 |
spriz |
but it would still contain `product_source_id` and `product_target_id` I guess? |
# |
Apr 9th 2019, 07:18 |
neon1024 |
So I could have a table with all the associations |
# |
Apr 9th 2019, 07:18 |
neon1024 |
Probably with a ‘many-to-many’ join |
# |
Apr 9th 2019, 07:18 |
neon1024 |
Then my UI would be a multi select of products for each type |
# |
Apr 9th 2019, 07:17 |
neon1024 |
@spriz I’d have another table for ‘product_associations’, with id, product_id, association_type_id |
# |
Apr 9th 2019, 07:15 |
spriz |
@conehead sounds like beforeMarshal :slightly_smiling_face: |
# |
Apr 9th 2019, 06:50 |
conehead |
Oh. BeforeValidate does not exist anymore |
# |
Apr 9th 2019, 06:45 |
conehead |
What would be the best place to convert date strings to date objects before saving. In before validate? Before save? |
# |
Apr 8th 2019, 19:08 |
blackjccl |
please help |
# |
Apr 8th 2019, 19:08 |
blackjccl |
He called the class well ´$pdf = new TCPDF('L',PDF_UNIT,PDF_PAGE_FORMAT,TRUE,'UTF-8',FALSE);´ |
# |
Apr 8th 2019, 19:07 |
blackjccl |
I do not know if in my configuration I have to do something else |
# |
Apr 8th 2019, 19:06 |
blackjccl |
Hi community I'm using plugin CakePdf with the library tcpdf and when generating the pdf it shows me the following error |