public function give() { $transaction = Yii::$app->db->beginTransaction(); $node = new Node(['type_id' => 4, 'user_name' => $this->user_name]); if ($node->invest()) { $this->node_id = $node->id; $this->save(); $node->user->setBundle(['node_id' => $node->type_id]); $node->user->save(); $transaction->commit(); return $node; } $transaction->rollBack(); return false; }
public function reinvest() { if ($this->getType()->reinvest) { $reinvest = new Node(['user_name' => $this->user_name, 'type_id' => $this->getType()->reinvest]); return $reinvest->invest(); } return false; }