public function postProfile(Request $request) { $userName = $request->input('name'); $userEmail = $request->input('email'); $userRealName = $request->input('realname'); $userSchool = $request->input('userSchoolName'); $userGrade = $request->input('userGrade'); $userOrder = $request->input('userOrder'); $userRole = $request->input('role'); $userDescription = $request->input('userDescription'); $currentUser = Auth::user(); //update user info $currentUser->description = $userDescription; $currentUser->name = $userName; $currentUser->realname = $userRealName; $currentUser->email = $userEmail; $currentUser->role = $userRole; $section = Section::getSectionByGradeAndOrder($userGrade, $userOrder, $userSchool); // find the matching section with grade and order. if (!$section) { // means don't exist this section, please create a new Section. $newSection = new Section(); $newSection->grade = $userGrade; $newSection->order = $userOrder; $newSection->schools_id = $userSchool; // setting the number of the section $newSection->total += 1; $newSection->save(); } else { // add the 1 to total number of the exist section $section->total += 1; } // 先去teachingSection table中查找到用户的对应信息 if ($userTeachingSection = TeachingSection::where()) { $currentUser->save(); } // the first method. /* session()->flash('flash_message', '你的个人信息修改成功'); session()->flash('flash_message_important', true);*/ /* return redirect('/dashboard')->with([ 'flash_message' => '你的个人信息修改成功', 'flash_message_important' => true ]);*/ // \Flash::success() // flash->success('你的个人信息修改成功'); // Flash::success('你的个人信息修改成功'); // flash()->success('你的个人信息修改成功'); flash()->overlay('你的个人信息修改成功', '成功'); return redirect('/dashboard'); }