public static function GetObject($subject_type, $subject_id) { switch ($subject_type) { case 'Program': return Program::findorFail($subject_id); break; case 'WorkStream': return WorkStream::findorFail($subject_id); break; case 'Project': return Project::findorFail($subject_id); break; case 'Risk': return Risk::findorFail($subject_id); break; case 'Task': return Task::findorFail($subject_id); break; case 'Action': return Action::findorFail($subject_id); break; case 'Rag': return rag::findorFail($subject_id); break; case 'Dependency': return Dependency::findorFail($subject_id); break; case 'ChangeRequest': return ChangeRequest::findorFail($subject_id); break; case 'Meeting': return Meeting::findorFail($subject_id); break; case 'Link': return Link::findorFail($subject_id); break; case 'Assumption': return Assumption::findorFail($subject_id); break; case 'Decision': return Decision::findorFail($subject_id); break; default: return null; } }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { //return $request->all(); $dependency = Dependency::findorFail($id); if (isset($request->dependent_on_id)) { //linked dependency $dependency->UpdateDependency(['status' => $request->status, 'title' => $request->title, 'description' => $request->description, 'NextReviewDate' => Carbon::parse($request->NextReviewDate)->toDateTimeString(), 'owner' => $request->owner, 'unlinked' => false, 'dependent_on_id' => $request->dependent_on_id, 'dependent_on_type' => $request->dependent_on_type, 'dependent_on_name' => Breadcrumbs::getSubjectName($request->dependent_on_type, $request->dependent_on_id)]); } else { //unlinked dependency $dependency->UpdateDependency(['status' => $request->status, 'title' => $request->title, 'description' => $request->description, 'NextReviewDate' => Carbon::parse($request->NextReviewDate)->toDateTimeString(), 'owner' => $request->owner, 'unlinked' => true, 'dependent_on_id' => 0, 'dependent_on_type' => 'External', 'dependent_on_name' => $request->freetextdependency]); } flash()->success('Success', "Dependency updated successfully"); return redirect(Session::GetRedirect()); }