0, 'msg' => '']; if ($response['err'] !== 0) { $timetable = ['err' => $response['err'], 'msg' => $response['msg']]; } if (array_key_exists('raspis', $response)) { foreach($response['raspis'] as $subject) { $timetable[$subject['week1']][$subject['day1']][$subject['time1']] = $subject; } foreach($timetable as $week => $day) { if (!is_array($day)) { continue; } foreach($day as $dayNumber => $subject) { $forSortSubjects = $timetable[$week][$dayNumber]; ksort($forSortSubjects); $timetable[$week][$dayNumber] = $forSortSubjects; } } } // dd($timetable); $getInfoOfStudent = new GetInfoOfStudent(new TestConnect()); $infoOfStudent = $getInfoOfStudent->getInfo($user); $apiHash = HashHelper::getApiHash($infoOfStudent); $recordHash = HashHelper::getRecordHash($user); if ($apiHash === $recordHash) { return view('dashboard', compact('user', 'currentWeek', 'timetable')); } $user->guid = $infoOfStudent['guid']; $user->guid_faculty = $infoOfStudent['guid_faculty']; $user->guid_group = $infoOfStudent['guid_group']; $user->name = $infoOfStudent['name']; $user->first_name = $infoOfStudent['first_name']; $user->last_name = $infoOfStudent['last_name']; $user->middle_name = $infoOfStudent['middle_name']; $user->number_record_book = $infoOfStudent['number_record_book']; $user->email = $infoOfStudent['email']; $user->faculty = $infoOfStudent['faculty']; $user->course = $infoOfStudent['course']; $user->group = $infoOfStudent['group']; $user->code = $infoOfStudent['code']; $user->form_education = $infoOfStudent['form_education']; $user->save(); $hashRecord = HashRecord::firstOrCreate(['user_id' => $user->id]); $hashRecord->hash = $apiHash; $hashRecord->save(); Cache::set($user->guid, json_encode($infoOfStudent)); return view('dashboard', compact('user', 'currentWeek', 'timetable')); } public function edit(Request $request): View { return view('profile.edit', [ 'user' => $request->user(), ]); } /** * Update the user's profile information. */ public function update(ProfileUpdateRequest $request): RedirectResponse { $request->user()->fill($request->validated()); if ($request->user()->isDirty('email')) { $request->user()->email_verified_at = null; } $request->user()->save(); return Redirect::route('profile.edit')->with('status', 'profile-updated'); } /** * Delete the user's account. */ public function destroy(Request $request): RedirectResponse { $request->validateWithBag('userDeletion', [ 'password' => ['required', 'current_password'], ]); $user = $request->user(); Auth::logout(); $user->delete(); $request->session()->invalidate(); $request->session()->regenerateToken(); return Redirect::to('/'); } }