Пример #1
0
 public function logout()
 {
     cookie::queue('uid', null, -1);
     cookie::queue('name', null, -1);
     cookie::queue('phone', null, -1);
     return redirect('/');
 }
Пример #2
0
 /**
  * 进行报名
  */
 public function signDo()
 {
     $rules = array('active_type' => 'required');
     $postData = Input::all();
     $validator = Validator::make($postData, $rules);
     if ($validator->fails()) {
         return Redirect::to('sign/' . Input::get('activeId'))->withErrors($validator);
     }
     $uid = cookie::get('uid');
     if ($uid) {
         //报名
         foreach ($postData['active_type'] as $type) {
             DB::table('active_user')->insert(['uid' => $uid, 'active_id' => Input::get('activeId'), 'active_type' => $type]);
         }
     } else {
         //注册+报名
         $phone = Input::get('phone');
         $name = Input::get('name');
         $rules = array('phone' => 'required', 'name' => 'required');
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             return Redirect::to('sign/' . Input::get('activeId'))->withErrors($validator);
         }
         $pass = '******';
         //user表写入数据,注册
         DB::table('user')->insert(['name' => $name, 'phone' => $phone, 'password' => md5($pass)]);
         //设置登陆
         $lastUid = DB::getPdo()->lastInsertId();
         cookie::queue('uid', $lastUid, 86400);
         cookie::queue('name', $name, 86400);
         cookie::queue('phone', $phone, 86400);
         //报名
         foreach ($postData['active_type'] as $type) {
             DB::table('active_user')->insert(['uid' => $lastUid, 'active_id' => Input::get('activeId'), 'active_type' => $type]);
         }
     }
     return redirect('/');
 }