コード例 #1
0
 /**
  * Retrieves the user information based on volunteer ID.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return  JSON  array of Volunteer information
  */
 public function retrieveUserDetails(Request $request)
 {
     // retrieve all details based on volunteer id
     $id = $request->get('id');
     $volunteer = Volunteer::with('rank')->where('volunteer_id', '=', $id)->get();
     $volunteerHours = Volunteer::findOrFail($id)->timeVolunteered();
     $volunteerRank = Volunteer::findOrFail($id)->rank_id;
     $volunteerRank = $volunteerRank - 1;
     if ($volunteerRank > 1) {
         $nextRank = Rank::findOrFail($volunteerRank);
     } else {
         $nextRank = '';
     }
     return response()->json(compact('volunteer', 'volunteerHours', 'nextRank'));
 }
コード例 #2
0
 /**
  * Show the information for the given volunteer.
  * Responds to requests to GET /volunteers/{id}
  *
  * @param  int  $id  the ID of the volunteer
  * @return Response
  */
 public function show($id)
 {
     $volunteer = Volunteer::with('activities')->findOrFail($id);
     return view('volunteers.show', compact('volunteer'));
 }