# |
Oct 8th 2018, 21:53 |
rightscoreanalysis |
that what I was thinking |
# |
Oct 8th 2018, 21:53 |
dereuromark |
also Hash::extract, combine etc can help here |
# |
Oct 8th 2018, 21:52 |
dereuromark |
instead, if you need, assign it to a different array. |
# |
Oct 8th 2018, 21:52 |
dereuromark |
dont do these kind of things |
# |
Oct 8th 2018, 21:51 |
rightscoreanalysis |
removing the [0] index from an array's index |
# |
Oct 8th 2018, 21:50 |
rightscoreanalysis |
foreach($propertyPeriods as and$period) { $period = $period[0]; } |
# |
Oct 8th 2018, 21:50 |
rightscoreanalysis |
is there a cake shorthand way to do this |
# |
Oct 8th 2018, 21:21 |
dereuromark |
foreach over it |
# |
Oct 8th 2018, 21:20 |
rightscoreanalysis |
back to the drawing board :slightly_smiling_face: |
# |
Oct 8th 2018, 21:17 |
rightscoreanalysis |
my known is the id - 103 |
# |
Oct 8th 2018, 21:17 |
rightscoreanalysis |
0 in an unknown |
# |
Oct 8th 2018, 21:17 |
rightscoreanalysis |
I have to use $property->property_periods[0] to gain access to the entity that has id 103 |
# |
Oct 8th 2018, 21:16 |
rightscoreanalysis |
but if in my template my date is in the var: $property->property_periods |
# |
Oct 8th 2018, 21:14 |
dereuromark |
you probably are. |
# |
Oct 8th 2018, 21:14 |
rightscoreanalysis |
i guess I am over-complicating this |
# |
Oct 8th 2018, 21:13 |
rightscoreanalysis |
I want to select the object by an id |
# |
Oct 8th 2018, 21:13 |
rightscoreanalysis |
yeah so I have an entity with 5 objects |
# |
Oct 8th 2018, 21:12 |
dereuromark |
but that is still the same entity |
# |
Oct 8th 2018, 21:12 |
rightscoreanalysis |
the entity is got through a contain on the sql query |
# |
Oct 8th 2018, 21:11 |
dereuromark |
you dont do this on the entity, this is a DTO, nothing else |
# |
Oct 8th 2018, 21:11 |
dereuromark |
also, you need to understand the basic ORM concepts. You can do get($id) on the table and then get the entity |
# |
Oct 8th 2018, 21:11 |
dereuromark |
you got the entity, why do you want it again? |
# |
Oct 8th 2018, 21:10 |
rightscoreanalysis |
there must be something similar in Cake? |
# |
Oct 8th 2018, 21:10 |
rightscoreanalysis |
I know that in Magento for example you can get by id on an object |
# |
Oct 8th 2018, 21:09 |
rightscoreanalysis |
in the above case 103 |
# |
Oct 8th 2018, 21:09 |
dereuromark |
->id ? |
# |
Oct 8th 2018, 21:01 |
rightscoreanalysis |
can do do something like $propertyPeriod->getId(103) |
# |
Oct 8th 2018, 21:00 |
rightscoreanalysis |
[ (int) 0 => object(App\Model\Entity\PropertyPeriod) { 'id' => (int) 103, 'property_id' => (int) 51, 'start_date' => object(Cake\I18n\FrozenTime) { |
# |
Oct 8th 2018, 21:00 |
rightscoreanalysis |
If i know the 'id' of PropertyPeriod: |
# |
Oct 8th 2018, 20:14 |
rightscoreanalysis |
brb |
# |
Oct 8th 2018, 20:13 |
rightscoreanalysis |
what I need is something like: $roomPricesByPeriod = $collection->groupBy('id'. 'start_date', 'end_date'); |
# |
Oct 8th 2018, 20:12 |
rightscoreanalysis |
$collection = new Collection($propertyTest); $roomPricesByPeriod = $collection->groupBy('id'); |
# |
Oct 8th 2018, 20:12 |
rightscoreanalysis |
so far I did this to group the ids which is what I need |
# |
Oct 8th 2018, 20:11 |
rightscoreanalysis |
I just need to extract the start_date and end_date from each index and put it in the top level |
# |
Oct 8th 2018, 20:11 |
rightscoreanalysis |
https://gist.github.com/spacebiscuit/dabfda259d39fd0cdcfc8032a3f58570 |
# |
Oct 8th 2018, 20:11 |
rightscoreanalysis |
@ricksaccous see this gist |
# |
Oct 8th 2018, 20:09 |
rightscoreanalysis |
I tried to read the book... after a while all of the methods look the same and I can't differentiate one form the other |
# |
Oct 8th 2018, 20:09 |
rightscoreanalysis |
yeah it looks super powerful |
# |
Oct 8th 2018, 20:09 |
ricksaccous |
it changes your life |
# |
Oct 8th 2018, 20:09 |
ricksaccous |
whatever you find works, but i'd recommend using collection magic |
# |
Oct 8th 2018, 20:08 |
rightscoreanalysis |
I might try and just hack it with a foreach |