/**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit(Request $request)
 {
     $m_session_id = $request->m_session_id;
     $mSession = MentorshipSession::find($m_session_id);
     $mSession->mentor_id = $request->mentor;
     $mSession->mentee_id = $request->mentee;
     $mSession->session_date = date("Y-m-d", strtotime($request->m_date));
     $mSession->facility = $request->m_facility;
     $mSession->self_reported_gap = $request->self_reported_gap;
     $mSession->previous_session_gap = $request->previous_session_gap;
     $mSession->other_gap = $request->other_gap;
     $mSession->session_objectives = $request->session_objectives;
     $mSession->mentee_strength = $request->mentee_strength;
     $mSession->mentee_improvement_areas = $request->mentee_improvement_areas;
     $mSession->session_comments = $request->session_comments;
     $mSession->cme_topic = $request->cme_topic;
     $mSession->cme_presenter = $request->cme_presenter;
     $mSession->mdt_participation = $request->mdt_participation;
     $mSession->session_score = $request->totalScore;
     $mSession->save();
     $sessionTool = $mSession->session_tool_id;
     switch ($sessionTool) {
         case 1:
             $formIndicators = FormIndicatorDefinitions::clinicalIndicators();
             break;
         case 2:
             $formIndicators = FormIndicatorDefinitions::laboratoryIndicators();
             break;
         case 3:
             $formIndicators = FormIndicatorDefinitions::counselingIndicators();
             break;
         case 4:
             $formIndicators = FormIndicatorDefinitions::nutritionIndicators();
             break;
         case 5:
             $formIndicators = FormIndicatorDefinitions::pharmacyIndicators();
             break;
     }
     foreach ($formIndicators as $ind) {
         $indNo = explode("_", $ind)[1];
         $indScore = $request->{$ind};
         $commentString = 'comm_' . $indNo;
         $comment = $request->{$commentString};
         $indicatorScore = MentorshipSessionScore::where(function ($query) use($m_session_id, $indNo) {
             $query->where('session_id', '=', $m_session_id)->where('indicator_id', '=', $indNo);
         })->first();
         $indicatorScore->score = $indScore;
         $indicatorScore->comment = $comment;
         $indicatorScore->save();
     }
     return redirect('mentorship-session');
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $mentorshipSession = MentorshipSession::find($id);
     $sessionDate = $mentorshipSession->created_at;
     $sessionTool = $mentorshipSession->sessionTool->name;
     $sessionToolId = $mentorshipSession->sessionTool->tool_id;
     $mentor = $mentorshipSession->mentor->person->first_name . " " . $mentorshipSession->mentor->person->last_name;
     $mentee = $mentorshipSession->mentee->person->first_name . " " . $mentorshipSession->mentee->person->last_name;
     $facility = $mentorshipSession->facility;
     $selfReportedGap = $mentorshipSession->self_reported_gap;
     $previousSessGap = $mentorshipSession->previous_session_gap;
     $otherGap = $mentorshipSession->other_gap;
     $sessionObjectives = $mentorshipSession->session_objectives;
     $menteeStrength = $mentorshipSession->mentee_strength;
     $improvementAreas = $mentorshipSession->mentee_improvement_areas;
     $comments = $mentorshipSession->session_comments;
     //create array to contain scores
     $sessionScores = $mentorshipSession->sessionScore;
     $sessionScore = array();
     foreach ($sessionScores as $score) {
         $ind = 'ind_' . $score->indicator_id;
         $comm = 'comm_' . $score->indicator_id;
         $indScore = $score->score;
         $indComment = $score->comment;
         $sessionScore["{$ind}"] = $indScore;
         $sessionScore["{$comm}"] = $indComment;
     }
     switch ($sessionToolId) {
         case 1:
             $viewPage = 'pages.session.tools.viewclinical';
             break;
         case 2:
             $viewPage = 'pages.session.tools.viewlaboratory';
             break;
         case 3:
             $viewPage = 'pages.session.tools.viewcounseling';
             break;
         case 4:
             $viewPage = 'pages.session.tools.viewnutrition';
             break;
         case 5:
             $viewPage = 'pages.session.tools.viewpharmacy';
             break;
     }
     return view($viewPage, compact('sessionDate', 'sessionTool', 'mentor', 'mentee', 'facility', 'sessionScore', 'selfReportedGap', 'previousSessGap', 'otherGap', 'sessionObjectives', 'menteeStrength', 'improvementAreas', 'comments'));
 }