/** * 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(); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show() { $report = Report::findByUser($this->user); $issues = []; if ($report) { foreach ($report->issues as $issue) { $url = explode('/', $issue['url']); $repo = implode('/', [$url[4], $url[5]]); if (!isset($issues[$repo])) { $issues[$repo] = new Collection(); } $issues[$repo]->push($issue); } } foreach ($issues as $repo => $issue) { $issues[$repo] = $issue->sortByDesc('number'); } return view('reports.show', ['user' => $this->user, 'report' => $issues]); }