コード例 #1
0
 /**
  * Responds to GET::/user/goals/edit.
  *
  * @return body.edit_goal view with a prepopulated form for editing a goal.
  */
 public function getEdit($goalID)
 {
     $goal = \App\Models\Goal::find($goalID);
     if ($goal && $goal->user_id == \Auth::User()->id) {
         $types = \App\Models\BodyMeasurementType::lists('name', 'id');
         $units = \App\Models\Unit::lists('abbreviation', 'id');
         return view('body.edit_goal')->with('types', $types)->with('goal', $goal)->with('units', $units);
     } else {
         \Session::flash('goal_update_error', 'You are not authorized to update this goal');
         return redirect('/goals');
     }
 }
コード例 #2
0
 /**
  * Responds to GET::/measurements/edit/{measurementID}. Returns the edit page
  * with existing measurement values already filled in.
  *
  * @param int $id The id of the measurement to edit.
  * @return body.edit_measurement view with measuremenet values already filled in
  */
 public function getEdit($id)
 {
     $measurement = \App\Models\BodyMeasurement::find($id);
     if ($measurement && \Auth::User()->id == $measurement->user_id) {
         $types = \App\Models\BodyMeasurementType::lists('name', 'id');
         $units = \App\Models\Unit::lists('abbreviation', 'id');
         return view('body.edit_measurement')->with('measurement', $measurement)->with('types', $types)->with('units', $units);
     } else {
         \Session::flash('mesaurement_update_error', 'You are not authorized to edit this measurement');
         return redirect('/measurements');
     }
 }