/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(PersonRequest $request)
 {
     $person = new Person();
     $person->first_name = $request->first_name;
     $person->middle_name = $request->middle_name;
     $person->last_name = $request->last_name;
     $person->gender = $request->gender;
     $person->cadre = $request->cadre;
     $person->email = $request->email;
     $person->phone = $request->phone;
     $person->facility = $request->facility;
     $person->save();
     $personId = $person->person_id;
     $pRole = $request->role;
     if ($pRole == 1) {
         $mentor = new Mentor();
         $mentor->person_id = $personId;
         $mentor->save();
     } else {
         $mentee = new Mentee();
         $mentee->person_id = $personId;
         $mentee->save();
     }
     return redirect('person-home');
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create($tool)
 {
     $mentors = Mentor::all();
     $mentees = Mentee::all();
     if ($tool == 1) {
         return view('pages.session.tools.clinical', compact('mentors', 'mentees'));
     } else {
         if ($tool == 2) {
             return view('pages.session.tools.laboratory', compact('mentors', 'mentees'));
         } else {
             if ($tool == 3) {
                 return view('pages.session.tools.counseling', compact('mentors', 'mentees'));
             } else {
                 if ($tool == 4) {
                     return view('pages.session.tools.nutrition', compact('mentors', 'mentees'));
                 } else {
                     if ($tool == 5) {
                         return view('pages.session.tools.pharmacy', compact('mentors', 'mentees'));
                     } else {
                         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->session_date;
     $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 = \DB::table('facility')->where('id', $mentorshipSession->facility)->first();
     $facility = $facility->mfl_code . ": " . $facility->name;
     $selfReportedGap = $mentorshipSession->self_reported_gap;
     $previousSessGap = $mentorshipSession->previous_session_gap;
     $otherGap = $mentorshipSession->other_gap;
     $sessionObjectives = $mentorshipSession->session_objectives;
     $mSessionId = $id;
     $menteeStrength = $mentorshipSession->mentee_strength;
     $improvementAreas = $mentorshipSession->mentee_improvement_areas;
     $comments = $mentorshipSession->session_comments;
     $cmeTopic = $mentorshipSession->cme_topic;
     $cmePresenter = $mentorshipSession->cme_presenter;
     $mdtParticipation = $mentorshipSession->mdt_participation;
     $totalScore = $mentorshipSession->session_score;
     //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;
     }
     $mentors = Mentor::all();
     $mentees = Mentee::all();
     $counties = \DB::table('county')->get();
     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('mSessionId', 'sessionDate', 'sessionTool', 'mentor', 'mentee', 'facility', 'sessionScore', 'selfReportedGap', 'previousSessGap', 'otherGap', 'sessionObjectives', 'menteeStrength', 'improvementAreas', 'comments', 'cmeTopic', 'cmePresenter', 'mdtParticipation', 'totalScore', 'mentors', 'mentees', 'counties'));
 }