public function registerDo() { // create the validation rules ------------------------ $rules = array('name' => 'required', 'phone' => 'required|phone|unique:user', 'password' => 'required|min:6', 'password_confirmation' => 'required|same:password'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to('register')->withErrors($validator)->withInput(Input::all()); } else { //注册 登陆 DB::table('user')->insert(['name' => Input::get('name'), 'phone' => Input::get('phone'), 'password' => md5(Input::get('password'))]); $id = DB::getPdo()->lastInsertId(); cookie::queue(cookie::make('uid', $id, 86400)); cookie::queue(cookie::make('name', Input::get('name'), 86400)); cookie::queue(cookie::make('phone', Input::get('phone'), 86400)); return Redirect::to('/'); } }