public function update(Request $request)
 {
     $iep = Iep::where('id', $request->json('iep'))->with('iepResponse')->first();
     $student = Student::where('id', $request->json('studentid'))->first();
     $user = User::where('dcid', $request->json('userdcid'))->first();
     $form = Form::where('id', $request->json('formid'))->with(['responses' => function ($query) use($student, $request) {
         if (!empty($request->json('responseid'))) {
             $query->where('id', $request->json('responseid'))->first();
         } else {
             $query->where('student_id', $student->id)->orderBy('whencreated', 'desc')->first();
         }
     }])->first();
     if ($iep->attach($form, $user)) {
         return (int) $form->responses[0]->id;
     }
     return 0;
 }
 protected function createIep($studentsdcid, $case_manager)
 {
     $iep = new Iep();
     $iep->studentsdcid = $studentsdcid;
     $iep->activated_at = new Carbon();
     $iep->case_manager = $case_manager;
     $iep->start_date = new Carbon();
     $iep->is_active = true;
     $iep->whocreated = 'IEP-PRINTING-PHP';
     $iep->whencreated = new Carbon();
     $iep->save();
     return $iep;
 }
Beispiel #3
0
 public function activate($student)
 {
     if ($this->canActivate()) {
         DB::transaction(function () use($student) {
             $activeIep = Iep::where(['is_active' => 1, 'studentsdcid' => $student->dcid])->update(['is_active' => 0]);
             $this->is_active = 1;
             $this->activated_at = new Carbon();
             $this->save();
         });
         return true;
     }
     return false;
 }
 public function activate(Request $request)
 {
     $iep = Iep::find($request->json('iep'));
     $student = Student::where('dcid', $request->json('student')['dcid'])->firstOrFail();
     if ($iep->activate($student)) {
         return 1;
     }
     return 0;
 }