/** * Execute the job. * * @return void */ public function handle(GitHubManager $github) { $github->authenticate($this->user->token, 'http_token'); $issues = new Collection(); foreach ($this->issues as $issue) { $i = explode('/', $issue); $issues->push((object) $github->issues()->show($i[0], $i[1], $i[2])); } if ($report = Report::findByUser($this->user)) { $report->issues = array_merge($report->issues, $issues); } else { $report = new Report(['user_id' => $this->user->id, 'issues' => $issues->sortByDesc('number')]); } return $report->save(); }