I have this query:
$result = $this->Status
->find()
->hydrate(false)
->contain([
'Proposals' => function ($q) {
$pendenteCase = $q->newExpr()->addCase(
$q->newExpr()->add(['status_id = 6']),
7,
'integer'
);
$q = $q
->select([
'Proposals.status_id' => $pendenteCase,
'count' => $q->func()->count('Proposals.id'),
'ano' => $q->func()->extract('YEAR', 'Proposals.created'),
'mes' => $q->func()->extract('MONTH', 'Proposals.created')
])
->group(['Proposals.status_id', 'ano', 'mes'])
->order(['ano' => 'ASC', 'mes' => 'ASC']);
return $q;
}
]
)
->where(function ($exp, $q) {
return $exp->notIn('id', [6, 5]);
});
But I got this error:
You are required to select the "Proposals.status_id" field(s)
How Can I do this works? Because I need that status_id
6 is counted with the status_id
7.