示例#1
0
 /**
  * 资料更新
  */
 public function update(Request $request, $id)
 {
     //基本信息
     if (!$request->isuser) {
         echo "<script>alert('用户类型必选!');history.go(-1);</script>";
         exit;
     }
     $user = ['email' => $request->email, 'qq' => $request->qq, 'tel' => $request->tel, 'mobile' => $request->mobile, 'isuser' => $request->isuser, 'isauth' => 1];
     UserModel::where('id', $id)->update($user);
     if (in_array($request->isuser, [1, 3])) {
         //个人信息
         if (!$request->realname) {
             echo "<script>alert('真实名字必填!');history.go(-1);</script>";
             exit;
         }
         if (!$request->idcard) {
             echo "<script>alert('身份证号码必填!');history.go(-1);</script>";
             exit;
         }
         $person = ['realname' => $request->realname, 'sex' => $request->sex, 'idcard' => $request->idcard, 'uid' => $id, 'created_at' => time()];
         PersonModel::create($person);
     } else {
         //公司信息
         $company = ['name' => $request->name, 'area' => $request->area, 'address' => $request->address, 'yyzzid' => $request->yyzzid, 'uid' => $id, 'created_at' => time()];
         CompanyModel::create($company);
         //插入搜索表
         $companyModel = CompanyModel::where($company)->first();
         \App\Models\Home\SearchModel::change($companyModel, 5, 'create');
     }
     return redirect(DOMAIN . 'member/setting');
 }
示例#2
0
 public function dologin()
 {
     $userModel = UserModel::where('username', Input::get('username'))->first();
     //查看是否有此用户
     if (!$userModel) {
         echo "<script>alert('没有此用户!');history.go(-1);</script>";
         exit;
     }
     //验证密码正确否
     if (!Hash::check(Input::get('password'), $userModel->password)) {
         echo "<script>alert('密码错误!');history.go(-1);</script>";
         exit;
     }
     //查看2次密码输入是否一致
     if (Input::get('password') != Input::get('password2')) {
         echo "<script>alert('2次密码输入不一致!');history.go(-1);</script>";
         exit;
     }
     //验证码验证
     $rules = ['captcha' => 'required|captcha'];
     $messages = ['captcha.required' => '请输入验证码', 'captcha.captcha' => '验证码错误,请重试'];
     $validator = Validator::make(Input::all(), $rules, $messages);
     if ($validator->fails()) {
         echo "<script>alert('验证码错误!');history.go(-1);</script>";
         exit;
     }
     //个人资料
     if (in_array($userModel->isuser, [1, 3])) {
         $personModel = PersonModel::where('uid', $userModel->id)->first();
         $persons['per_id'] = $personModel->id;
         $persons['realname'] = $personModel->realname;
         $persons['sex'] = $personModel->sex;
         $persons['idcard'] = $personModel->idcard;
         $persons['idfront'] = $personModel->idfront;
     }
     $userperson = isset($persons) ? serialize($persons) : [];
     //企业资料
     if (in_array($userModel->isuser, [2, 4])) {
         $companyModel = CompanyModel::where('uid', $userModel->id)->first();
         $companys['cid'] = $companyModel->id;
         $companys['name'] = $companyModel->name;
         $companys['area'] = $companyModel->area;
         $companys['address'] = $companyModel->address;
         $companys['yyzzid'] = $companyModel->yyzzid;
     }
     $usercompany = isset($companys) ? serialize($companys) : [];
     $serial = date('YmdHis', time()) . rand(0, 10000);
     $userInfo = ['uid' => $userModel->id, 'username' => Input::get('username'), 'email' => $userModel->email, 'userType' => $userModel->isuser, 'serial' => $serial, 'area' => $userModel->area, 'address' => $userModel->address, 'cid' => isset($companyModel) ? $companyModel->id : '', 'loginTime' => time(), 'person' => $userperson, 'company' => $usercompany];
     Session::put('user', $userInfo);
     //登陆加入用户日志表
     $ip = \App\Tools::getIp();
     $ipaddress = \App\Tools::getCityByIp($ip);
     $userlog = ['uid' => $userModel->id, 'uname' => Input::get('username'), 'genre' => 1, 'serial' => $serial, 'ip' => $ip, 'ipaddress' => $ipaddress, 'action' => $_SERVER['REQUEST_URI'], 'loginTime' => time(), 'created_at' => $userModel->created_at];
     LogModel::create($userlog);
     //最近登录更新
     UserModel::where('id', $userModel->id)->update(['lastLogin' => time()]);
     return redirect(DOMAIN . 'member');
 }
示例#3
0
 public function show($id)
 {
     $curr['name'] = $this->crumb['show']['name'];
     $curr['url'] = $this->crumb['show']['url'];
     $userModel = UserModel::find($id);
     if (in_array($userModel->isuser, [2, 4])) {
         $personModel = PersonModel::where('uid', $id)->first();
     } elseif (in_array($userModel->isuser, [2, 5, 6, 7])) {
         $companyModel = CompanyModel::where('uid', $id)->first();
     }
     $result = ['data' => $userModel, 'personModel' => isset($personModel) ? $personModel : '', 'companyModel' => isset($companyModel) ? $companyModel : '', 'crumb' => $this->crumb, 'curr' => $curr];
     return view('admin.user.show', $result);
 }
示例#4
0
 /**
  * 会员个人信息
  */
 public function person()
 {
     return PersonModel::where('uid', $this->id)->first();
 }