/**
  * 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');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $mSession = new MentorshipSession();
     $mSession->mentor_id = $request->mentor;
     $mSession->mentee_id = $request->mentee;
     $mSession->session_tool_id = $request->tool_id;
     $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->save();
     $sessionId = $mSession->session_id;
     switch ($request->tool_id) {
         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 = new MentorshipSessionScore();
         $indicatorScore->session_id = $sessionId;
         $indicatorScore->indicator_id = $indNo;
         $indicatorScore->score = $indScore;
         $indicatorScore->comment = $comment;
         $indicatorScore->save();
     }
     return redirect('mentorship-session');
 }