I have specific task to display data in two parallel html tables. In one table must display records only if contain model not have any data, on second if contain model have data.
working example:
$example->items = $this->Items->find()
->contain(['Parent']) // hasOne
->where([
'Items.uuid' => $uuid,
'Parent.id IS NULL', // <---- this is little hack that help us to select data only if no parent data
])
->toArray();
But how to in:
$this->Example->find()
->where([
'Example.uuid' => $uuid,
'Example.type' => 'default',
])
->contain(['User'])
->contain(['Items.Parent']) // set condition here to receive data only if Parent model not contain data???
->first();