/** * Handle the update issue command. * * @param \Gitamin\Commands\Issue\UpdateIssueCommand $command * * @return \Gitamin\Models\Issue */ public function handle(UpdateIssueCommand $command) { $issue = $command->issue; $issue->update($this->filter($command)); // The issue occurred at a different time. if ($command->issue_date) { $issueDate = $this->dates->createNormalized('d/m/Y H:i', $command->issue_date); $issue->update(['created_at' => $issueDate, 'updated_at' => $issueDate]); } event(new IssueWasUpdatedEvent($issue)); return $issue; }
/** * Handle the report issue command. * * @param \Gitamin\Commands\Issue\AddIssueCommand $command * * @return \Gitamin\Models\Issue */ public function handle(AddIssueCommand $command) { $data = ['name' => $command->name, 'status' => $command->status, 'message' => $command->message, 'visible' => $command->visible]; // Link with the user. if ($command->user_id) { $data['user_id'] = $command->user_id; } // Link with the project. if ($command->project_id) { $data['project_id'] = $command->project_id; } // The issue occurred at a different time. if ($command->issue_date) { $issueDate = $this->dates->createNormalized('d/m/Y H:i', $command->issue_date); $data['created_at'] = $issueDate; $data['updated_at'] = $issueDate; } // Create the issue $issue = Issue::create($data); $issue->notify = (bool) $command->notify; event(new IssueWasAddedEvent($issue)); return $issue; }