# |
Nov 6th 2019, 10:33 |
jotpe |
Anyone has experience with wkhtmltopdf and the local php built-in webserver? I need to generate PDFs and this works on my remote development server, but not local (recent wkhtmltopdf with qt patched) and php 7.2 |
# |
Nov 6th 2019, 10:29 |
dev.cyrusjayson |
Thanks @javier.villanueva |
# |
Nov 6th 2019, 10:28 |
javier.villanueva |
this example is from https://book.cakephp.org/3/en/orm/associations.html |
# |
Nov 6th 2019, 10:27 |
slackebot1 |
->setConditions(['WorkAddress.label' => 'Work']) ->setDependent(true); } } ``` |
# |
Nov 6th 2019, 10:27 |
javier.villanueva |
```{ public function initialize(array $config) { $this->hasOne('HomeAddress', [ 'className' => 'Addresses' ]) ->setProperty('home_address') ->setConditions(['HomeAddress.label' => 'Home']) ->setDependent(true); $this->hasOne('WorkAddress', [ 'className' => 'Addresses' ]) ->setProperty('work_address') |
# |
Nov 6th 2019, 10:27 |
javier.villanueva |
one example |
# |
Nov 6th 2019, 10:26 |
dev.cyrusjayson |
and how the associations looks like in the model ? |
# |
Nov 6th 2019, 10:26 |
javier.villanueva |
Matches hasOne AwayTeam |
# |
Nov 6th 2019, 10:25 |
javier.villanueva |
Matches hasOne HomeTeam |
# |
Nov 6th 2019, 10:25 |
javier.villanueva |
away_team_id |
# |
Nov 6th 2019, 10:25 |
javier.villanueva |
home_team_id |
# |
Nov 6th 2019, 10:23 |
dev.cyrusjayson |
I have Matches model and it has two fields coming from Teams model. so the Matches model has this ``` Teams id *Matches* team_1 <team id> FK team_2 <team id> FK ``` what is the proper way? |
# |
Nov 6th 2019, 10:16 |
javier.villanueva |
In other hand my other option is to have one entity Reports and related with model with A fields, model with B fields, model with C fields.... |
# |
Nov 6th 2019, 10:12 |
javier.villanueva |
Hi... if anyone can advise me. I have the next structure Reports (Reports A with any fields, Reports B with other fields, Reports C...). My doubt is if I create one entity for each type of Report (cause fields are very differents), different tables for each report type, etc. Its important that this Reports have a relationship with a Workorder [hasMany Reports]. |
# |
Nov 6th 2019, 09:22 |
markwendelson |
add parent::initialize(); solves the problem |
# |
Nov 6th 2019, 09:08 |
markwendelson |
getting error when doing this in a controller |
# |
Nov 6th 2019, 08:58 |
pidlo |
ok i get this $query->newExpr('DATE_ADD(dfrom, INTERVAL - @num MONTH)') |
# |
Nov 6th 2019, 08:50 |
kgb.acct.personal |
It's not that inconvenient to be honest. |
# |
Nov 6th 2019, 08:48 |
conehead |
That might be true. Not as convinient as it could be :P |
# |
Nov 6th 2019, 08:44 |
admad |
`'comment_id' => 1` is the same as saving any other field. There's no special handling there. While `_ids` is a special convention |
# |
Nov 6th 2019, 08:42 |
conehead |
just to save it the same way. I get your point. But both are associations and the way they are stored are different |
# |
Nov 6th 2019, 08:41 |
conehead |
I am just saying: you set a `belongsTo` as `'comment_id' => 1`, but a `belongsToMany` as `'comment' => ['_ids' => [1,2,3]]. why not save a `belongsToMany` as `'comment_ids' => [1,2,3]` or a `belongsTo` as `'comment' => ['_id' => 1]` imho that would be more convinient |
# |
Nov 6th 2019, 08:38 |
admad |
that's a hasMany, not belonsTo |
# |
Nov 6th 2019, 08:37 |
conehead |
Or the other way around would be to allow for multiple associations to set e.g. `new Post(['comment_ids' => [1,2,3])` |
# |
Nov 6th 2019, 08:35 |
conehead |
Think it would be common sense that you could handle different associations similar |
# |
Nov 6th 2019, 08:33 |
admad |
why? there's only a single fK value for belongsTo |
# |
Nov 6th 2019, 08:31 |
conehead |
@admad Yes thanks. That works. Just wondering if this example is not a little bit confusing then: https://book.cakephp.org/3/en/orm/saving-data.html#saving-belongsto-associations Something similar like `_ids` would be great I think |
# |
Nov 6th 2019, 08:28 |
pidlo |
something like this? $query->func()->dateAdd('dfrom', @num, 'MONTH') ??? |
# |
Nov 6th 2019, 08:28 |
pidlo |
howto do this 'DATE_ADD(dfrom, INTERVAL - @num MONTH)' |
# |
Nov 6th 2019, 08:28 |
pidlo |
hello all i have registred variable in sql '@num:=CAST(period AS UNSIGNED)', |
# |
Nov 6th 2019, 08:26 |
admad |
@conehead to associate with existing record just set the foreign key, `attachement_id` in your case |
# |
Nov 6th 2019, 08:24 |
scuadra |
Hello everyone. In Cake 3 is it possible to define the fields to be fetched in belongsTo association in the initialize() method? |
# |
Nov 6th 2019, 08:21 |
conehead |
Still thinks that the created entity is "new". Doesn't seem to recognize the id |
# |
Nov 6th 2019, 08:21 |
conehead |
Good morning |
# |
Nov 6th 2019, 08:20 |
rudy1976s |
good morning to all !!! |
# |
Nov 6th 2019, 08:18 |
conehead |
Hm I'll give it a shot. But it is not a new entity and it works with other `belongs to many` without `associated` as well |
# |
Nov 6th 2019, 08:16 |
dereuromark |
Uppercase first char usually as those are the model names. |
# |
Nov 6th 2019, 08:14 |
karmicdice |
`'associated' => ['attachments']` |
# |
Nov 6th 2019, 08:14 |
karmicdice |
maybe parameter 2 should be `'associated'` ? |
# |
Nov 6th 2019, 08:13 |
conehead |
All I want to do is save an association. It even saves null, when I do ``` $attachment = $this->Attachments->get(1); $post = $this->Posts->newEntity([ 'name' => 'newPost', 'attachment' => $attachment, ]); |
# |
Nov 6th 2019, 08:11 |
karmicdice |
I reckon, it saves a null when you do not add an attachment? For situations like these, have you considered writing a behaviour and utilizing `beforeSave()`. What is the exact scenario and what are you trying to achieve? |