# |
May 30th 2021, 01:23 |
davinci |
I'm sure I'm missing something obvious, but can't think of it |
# |
May 30th 2021, 01:23 |
davinci |
Want to limit a contained data set to 10 Prices for each PriceSource, but doing it like this limits to 10 total: ```->contain([ 'PriceSources' => [ 'Prices' => function (Query $q) { return $q->where(['Prices.model'=>'Car', 'foreign_key'=>123456])->order(['Prices.date' => 'DESC'])->limit(10); }, ] ])``` |
# |
May 29th 2021, 22:50 |
kevin.pfeifer |
:+1::the_horns: |
# |
May 29th 2021, 22:47 |
etibor |
Kevin thank you really much i think the hard part is over, now i hope i will manage if not i will ask a little more help nex time |
# |
May 29th 2021, 22:43 |
kevin.pfeifer |
puh, dont really know. guess foreach |
# |
May 29th 2021, 22:42 |
etibor |
or is there an easier way? |
# |
May 29th 2021, 22:42 |
etibor |
should i go through wit a foreach ? |
# |
May 29th 2021, 22:41 |
etibor |
yes beacuse on the form there are multiple score form fields |
# |
May 29th 2021, 22:40 |
kevin.pfeifer |
but if at least you can get to the data ^^ |
# |
May 29th 2021, 22:40 |
kevin.pfeifer |
mhmm ok, could be that this is a difference from cake3 to 4 |
# |
May 29th 2021, 22:39 |
etibor |
the (false) data field is avaliable in a _joinData |
# |
May 29th 2021, 22:29 |
etibor |
moment please |
# |
May 29th 2021, 22:29 |
kevin.pfeifer |
before you call the save function |
# |
May 29th 2021, 22:28 |
kevin.pfeifer |
do you contain the storage model? |
# |
May 29th 2021, 22:28 |
kevin.pfeifer |
in your edit function |
# |
May 29th 2021, 22:28 |
kevin.pfeifer |
ok and in your controller |
# |
May 29th 2021, 22:28 |
etibor |
it does not show the Storage Model's field values |
# |
May 29th 2021, 22:27 |
etibor |
okey var_dump helped to print out |
# |
May 29th 2021, 22:26 |
kevin.pfeifer |
or after the add |
# |
May 29th 2021, 22:25 |
kevin.pfeifer |
so like parallel to the add |
# |
May 29th 2021, 22:25 |
kevin.pfeifer |
if you put a die outside of that function does it then stop? |
# |
May 29th 2021, 22:24 |
kevin.pfeifer |
:thinking_face: |
# |
May 29th 2021, 22:24 |
etibor |
but its just jump over and display save successfull message |
# |
May 29th 2021, 22:24 |
etibor |
i tried to debug the entity: $rules->add(function ($entity, $options) {debug($entity);die; |
# |
May 29th 2021, 22:24 |
kevin.pfeifer |
so like `$this->Documents->get($id)->contain('Storage')` |
# |
May 29th 2021, 22:23 |
kevin.pfeifer |
when you do the save function on the entity it needs to already contain the connected data |
# |
May 29th 2021, 22:22 |
kevin.pfeifer |
where i have my ->contain() in the query |
# |
May 29th 2021, 22:22 |
etibor |
in an edit |
# |
May 29th 2021, 22:22 |
kevin.pfeifer |
i just checked in the edit form before |
# |
May 29th 2021, 22:21 |
kevin.pfeifer |
are you in an add form or in the edit form? |
# |
May 29th 2021, 22:21 |
etibor |
are you sure "has already the connected entities in there" ? |
# |
May 29th 2021, 22:21 |
kevin.pfeifer |
hmm |
# |
May 29th 2021, 22:21 |
etibor |
i got this error Trying to get property 'max' of non-object |
# |
May 29th 2021, 22:14 |
etibor |
if this will work you save me from a lot of stress |
# |
May 29th 2021, 22:14 |
etibor |
i am going to implement |
# |
May 29th 2021, 22:14 |
etibor |
:) |
# |
May 29th 2021, 22:13 |
kevin.pfeifer |
otherwise you know where to find me ;P |
# |
May 29th 2021, 22:12 |
kevin.pfeifer |
i hope with that rule your problem is solved |
# |
May 29th 2021, 22:12 |
kevin.pfeifer |
dude wow, thank you ,:) |
# |
May 29th 2021, 22:10 |
etibor |
Thank you Kevin really much your help, just think to your cake friend while having the coffe |
# |
May 29th 2021, 22:06 |
kevin.pfeifer |
well I have a “Buy me a Coffee” Button on https://www.devguide.at/en/kategorie/backend/php/ if you really really really want to give me something But again, you don’t need to do that! |