示例#1
0
 /**
  * 个人信息
  */
 public function profile(Request $request)
 {
     if ($request->isMethod('get')) {
         $oManagerInfo = Admin::findOrFail($request->session()->get('admin_id'));
         $aGroups = Admin::get_groups_info(session('admin_id'));
         return view('admin.manager.profile', ['manager_info' => $oManagerInfo, 'groups' => $aGroups]);
     }
     if (!$request->isMethod('post')) {
         App::abort(404);
     }
     // post请求,只能修改自己的邮箱
     if ($request->has('email')) {
         if (filter_var($request->input('email'), FILTER_VALIDATE_EMAIL)) {
             $oAdmin = Admin::findOrFail($request->session()->get('admin_id'));
             $oAdmin->email = $request->input('email');
             $oAdmin->save();
         } else {
             //email格式不对
             $request->session()->flash('msg_error', '邮箱格式不正确');
             return back();
         }
     }
     $request->session()->flash('msg_success', '个人资料已更新');
     return back();
 }