I’ve been trying to use scopes inside the with option and haven’t been able to figure out how. Here’s an example setup similar to mine:
ParentModel has the following scopes
"getValidatedEntries" => array(
"condition" = "valid = 1",
)
ChildModel belongs to ParentModel
I’m trying to use the scope like this:
$validChildModels = $childModel(array(
'with' => array(
'parentModel' => array(
'scopes' => array(
'getValidatedEntries',
),
),
),
));
Doing it this way, I end up losing parentModel for some reason ($validChildModel->parentModel becomes null)
But if I run the code without using the scope like this
$validChildModels = $childModel(array(
'with' => array(
'parentModel' => array(
'condition' = 'valid = 1',
),
),
));
it works fine. Any idea what I’m doing wrong?