user = $user->fresh(); $this->perf = $perf; $this->source = $source; } /** * 添加业绩 * @return [type] [description] */ public function fire() { $data = [ 'user_id' => $this->user->id, 'perf' => $this->perf, 'from_id' => $this->user->id, 'source' => json_encode($this->source), 'created_at' => now()->format('Y-m-d H:i:s'), 'updated_at' => now()->format('Y-m-d H:i:s'), ]; $parent = $this->user; $lists = []; while ($parent) { $data['user_id'] = $parent->id; $lists[] = $data; $parent = $parent->parent; } if (count($lists) > 0) { UserPerf::insert($lists); } } }