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; } }
public static function getSubjectName($subjecttype, $subjectid) { switch ($subjecttype) { case "Program": $program = Program::findOrFail($subjectid); return $program->name; break; case "WorkStream": $workstream = WorkStream::findOrFail($subjectid); return $workstream->name; break; case "Project": $project = Project::findOrFail($subjectid); return $project->name; break; case "Risk": $risk = Risk::findOrFail($subjectid); return $risk->title; break; case "Rag": $rag = rag::findOrFail($subjectid); return $rag->title; break; case "Task": $task = Task::findOrFail($subjectid); return $task->title; break; case "Dependency": $dependency = Dependency::findOrFail($subjectid); return $dependency->title; break; case "ChangeRequest": $changerequest = ChangeRequest::findOrFail($subjectid); return $changerequest->title; break; case "Meeting": $meeting = Meeting::findOrFail($subjectid); return $meeting->title; break; case "Action": $action = Action::findOrFail($subjectid); return $action->title; break; case "Link": $link = Link::findOrFail($subjectid); return $link->title; break; case "Assumption": $assumption = Assumption::findOrFail($subjectid); return $assumption->title; break; } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { try { $changerequest = ChangeRequest::findOrFail($id); } catch (ModelNotFoundException $e) { abort(404, "Change Request with id {$id} not found"); } $changerequest->delete(); flash()->success('Success', "Change Request deleted successfully"); return redirect()->back(); }