/** * Set the status of a sprint to complete, if all issues in this sprint are complete * @param Request * @return array $result */ public function complete(Request $request) { // default $result = array('message' => 'There was an error processing this request', 'status' => 0); $sprintName = $request->sprintMachineName; $projectId = $request->projectId; $sprint = Sprint::where('machine_name', '=', $sprintName)->where('project_id', '=', $projectId)->firstOrFail(); if ($sprint && $sprint->isComplete()) { $sprint->status_id = SprintStatus::getIdByMachineName('complete'); $sprint->save(); $result = array('message' => 'This sprint has been set to complete', 'sprintMachineName' => $sprintName, 'status' => 1); } else { $result = array('message' => 'All issues in the sprint should be complete or archived before setting a sprint to complete', 'sprintMachineName' => $sprintName, 'status' => 0); } return $result; }
/** * Get the active sprint for a given project * @return first sprint from collection */ public function getActiveSprint() { return $this->sprints()->where('status_id', '=', SprintStatus::getIdByMachineName('active'))->get()->first(); }