Hi All
I have two models one is Orders and one is Budgets.
I want to calculate remaining amount for a Budget category afterFind on the Budget model.
Can I use $this->id in my expression to calculate the remainding?
The following just causes my page to hang, no errors:
protected function afterFind ()
{
$this->remaining = $this->cat_budget;
$tmp = Order::model()->findAll('catid=:c1',array(':c1'=>$this->id));
foreach ($tmp as $val) {
if (is_numeric($val->total)) {
$this->remaining -= $val->total;
}
}
}
Any suggestions?
Thanks
Johan