Hi All,
I have a table, product with 2 STAT relationship to other table productIssuedQty (sum of quantity being issued) and productReceivedQty (sum of quantity being received). In the product table, it has a field named "status", it can be 0: FINISHED or 1: ACTIVE. In the beginning, the status is 1 (ACTIVE) If productIssuedQty >= productReceivedQty, it should change the status to 0 (FINISHED).
At the moment, I used this workaround, in the models/Product.php
public function afterFind() {
if($this->receivedQty <= $this->issuedQty) {
$this->status = self::FINISHED;
$this->save();
}
}
Any better suggestion? Since using this, I feel uncomfortable and afraid of performance issue.
Thanks in advance.