/** * 检查用户名是否被注册 * * @param null $username * @return null */ public static function user($username = null) { $ret = false; if ($username) { $user = PhoneUser::where(['username' => $username])->get(); if (count($user)) { $ret = $user[0]; } } return $ret; }
public function handle($request, Closure $next) { $uid = Session::get('uid'); if (PhoneUser::find($uid ? $uid : 0)) { CallBack::remove(); return $next($request); } else { CallBack::set($this->generator->current()); return redirect('login'); } }
public function details($id) { if ($id) { if (VerifyUser::shipping(Session::get('uid'))) { $data = []; $data['id'] = $id; $data['user'] = PhoneUser::find(Session::get('uid')); $data['product'] = PhoneSku::find($id); return view('home.order.details')->with($data); } else { return redirect('my/shipping/create'); } } else { return redirect()->back(); } }
/** * 用户管理 * * @return mixed */ public function memberShow() { return view('admin.users.member')->withMembers(PhoneUser::orderBy('id', 'DESC')->paginate(10)); }
/** * 注册用户 * * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function userCreate() { $username = Input::get('username', null); $pwd = Input::get('password', null); $pwdDouble = Input::get('password-double', null); if (VerifyUser::phoneCode($username)) { flash('亲,用户名必须是手机号码哦~重试一下吧'); return redirect()->back(); } if (strlen($pwd) < 6 or strlen($pwd) > 16) { flash('亲,密码最少需要6位哦~重试一下吧'); return redirect()->back(); } if ($pwd != $pwdDouble) { flash('亲,两次密码输入不一致哦~重试一下吧'); return redirect()->back(); } if (VerifyUser::user($username)) { flash('亲,该用户名已经被注册啦~'); return redirect()->back(); } $user = new PhoneUser(); $user->username = $username; $user->password = md5($pwd); if ($user->save()) { Session::set('uid', $user->id); Session::set('username', $user->username); if (CallBack::has()) { return redirect(CallBack::get()); } else { return redirect('/'); } } else { flash('亲,服务器现在压力山大~再试一下吧'); return redirect()->back(); } }