Skip to content

Instantly share code, notes, and snippets.

@spacebiscuit

spacebiscuit/php Secret

Created October 6, 2018 23:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spacebiscuit/13497a100c2f6c453c4f3d097dd78498 to your computer and use it in GitHub Desktop.
Save spacebiscuit/13497a100c2f6c453c4f3d097dd78498 to your computer and use it in GitHub Desktop.
$options = ['Properties.id' => $id];
$contains = [
'PropertyImages' => [
'sort' => ['PropertyImages.sort_order' => 'ASC', 'PropertyImages.id' => 'ASC']
],
'PropertyPeriods' => [
'sort' => [
'PropertyPeriods.start_date' => 'ASC'
],
'Properties' => [
'Rooms' => [
'PropertyPrices' => function($q) {
return $q
->select(['PropertyPrices.room_id'])
->where([
'Rooms.id' => 'PropertyPrices.room_id'
])
;
}
]
]
],
];
$property = $this->Properties->find()->where($options)->contain($contains)->first();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment