getChangedData(); if (isset($changedData['status']) && $row->goods) { if ($changedData['status'] == 'normal') { $row->goods->setInc('comments'); } else { if ($row->goods->comments > 0) { $row->goods->setDec('comments'); } } } }); self::afterDelete(function ($row) { if ($row['pid']) { \addons\shop\model\Comment::where('id', $row['pid'])->setDec('comments'); } }); } public function getStatusList() { return ['normal' => __('Normal'), 'hidden' => __('Hidden')]; } public function getStatusTextAttr($value, $data) { $value = $value ?: ($data['status'] ?? ''); $list = $this->getStatusList(); return $list[$value] ?? ''; } public function User() { return $this->hasOne('\\app\\common\\model\\User', 'id', 'user_id', [], 'LEFT'); } public function Goods() { return $this->hasOne('Goods', 'id', 'goods_id', [], 'LEFT'); } }