/**
  * Store a newly created resource in storage.
  *
  * @return \Illuminate\Http\Response
  */
 public function store()
 {
     if (!Input::get('attendee_id') or !Input::get('program_id')) {
         return $this->respondUnprocessableEntity('Parameters failed validation for an enrollment.');
     }
     try {
         $attendee = Attendee::findOrFail(Input::get('attendee_id'));
     } catch (ModelNotFoundException $e) {
         return $this->respondUnprocessableEntity('Attendee provided does not exist.');
     }
     try {
         $program = Program::findOrFail(Input::get('program_id'));
     } catch (ModelNotFoundException $e) {
         return $this->respondUnprocessableEntity('Program provided does not exist.');
     }
     $existingEnrollment = Enrollment::where('attendee_id', $attendee->id)->where('program_id', $program->id)->whereNull('enrollments.deleted_at')->get();
     if (count($existingEnrollment)) {
         return $this->respondUnprocessableEntity('The enrollment of the attendee to the program already exists.');
     }
     //We pass validation. Now add the enrollment.
     Enrollment::create(Input::all());
     return $this->respondCreated('Enrollment created successfully.');
 }
 /**
  * Displays the counselor that an attendee is assigned to.
  *
  * @return \Illuminate\Http\Response
  */
 public function byAttendee($attendeeId = null)
 {
     $counselor = $attendeeId ? Attendee::findOrFail($attendeeId)->counselor : null;
     return $this->respond(['data' => $this->counselorTransformer->transform($counselor)]);
 }