function the_static($filename = '') { echo get_static($filename); }
/** * 注册Action * @return mixed * @author AndyLee <*****@*****.**> */ public function postRegister() { $input = Input::Only('phone', 'nickname', 'secret', 'captcha'); $rules = ['phone' => 'required|Regex:/^1[0-9]{10}$/|unique:user_operators,mobile', 'nickname' => 'required|min:2|max:8', 'secret' => 'required|min:6|max:16', 'captcha' => 'required']; $message = ['phone.required' => '手机号码必填', 'phone.Regex' => '手机号码不规范', 'phone.unique' => '手机号码已存在', 'nickname.required' => '昵称必填', 'nickname.min' => '昵称最少2位', 'nickname.max' => '昵称最长8位', 'secret.required' => '密码必填', 'secret.min' => '密码最少6位', 'secret.max' => '密码最长16位', 'captcha' => '短信验证码必填']; $v = Validator::make($input, $rules, $message); if ($v->fails()) { Session::flash('error', $v->messages()->first()); return Redirect::to('/auth/register'); } $captcha = Cache::get($input['phone']); if ($captcha != $input['captcha']) { Session::flash('error', '短信验证码不正确'); return Redirect::to('/auth/register'); } /** * 验证完成 */ $operator = new User(); $operator->mobile = $input['phone']; $operator->username = $input['nickname']; $operator->password = Hash::make($input['secret']); $operator->avatar = get_static('assets/avatar/' . mt_rand(1, 43) . '.png'); $operator->save(); /** * 注册完成,自动登录 */ Auth::attempt(['mobile' => $input['phone'], 'password' => $input['secret']]); Session::flash('success', '注册成功,系统已经自动为您登录'); return redirect()->intended('/'); }