public function index(Request $request) { if ($request->has('frn') && $request->has('user')) { $data = ['frn' => $request->get('frn'), 'user' => User::where('dcid', $request->get('user'))->firstOrFail(), 'student' => Student::where('dcid', substr($request->get('frn'), 3))->firstOrFail(), 'ieps' => Iep::where('studentsdcid', substr($request->get('frn'), 3))->orderBy('start_date', 'desc')->get(), 'portal' => $request->get('portal')]; return view('frame.index', $data); } return 'IEP Printing!'; }
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; }
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; }