Exemplo n.º 1
0
 public function getSchools()
 {
     $key = Input::get('key', '');
     $province = Input::get('province', '');
     $city = Input::get('city', '');
     try {
         $query = \DicSchool::where('t_type', '=', '1');
         if ($key) {
             $query = $query->where('t_name', 'LIKE', '%' . $key . '%');
         }
         if ($province) {
             $query = $query->where('t_province', '=', $province);
         }
         if ($city) {
             $query = $query->where('t_city', '=', $city);
         }
         $list = $query->orderBy('t_name')->get();
         $data = [];
         foreach ($list as $key => $school) {
             $data[] = $school->showInList();
         }
         $paginate = ['total_record' => $list->count(), 'total_page' => 1, 'per_page' => $list->count(), 'current_page' => 1];
         $re = ['result' => 2000, 'data' => $data, 'info' => '获取学校成功', 'pagination' => $paginate];
     } catch (Exception $e) {
         $re = ['result' => 2001, 'data' => [], 'info' => '获取学校失败:' . $e->getMessage()];
     }
     return Response::json($re);
 }
Exemplo n.º 2
0
 public function login($u_id)
 {
     $user = User::find($u_id);
     if (empty($user)) {
         throw new Exception("没有找到用户", 3005);
     }
     if ($user->u_status != 1) {
         throw new Exception("您的账号不可用, 请联系客服", 3005);
     }
     $re = [];
     $re['token'] = $user->u_token;
     $now = new Datetime();
     $now->modify('+ 30 days');
     $re['expire'] = $now->format('Y-m-d H:i:s');
     $re['id'] = $user->u_id;
     $re['name'] = $user->u_name = $this->u_nickname;
     $re['nickname'] = $user->u_nickname = $this->u_nickname;
     $re['invite_code'] = $user->u_invite_code;
     $re['head_img'] = $user->u_head_img = $this->u_head_img;
     $re['biograph'] = $user->u_biograph;
     $school = DicSchool::find($user->u_school_id);
     if (empty($school)) {
         $re['city'] = null;
         $re['school'] = null;
     } else {
         $re['city'] = DicCity::where('c_id', '=', $school->t_city)->where('c_province_id', '=', $school->t_province)->first()->showInList();
         $re['school'] = $school->showInList();
     }
     $user->save();
     $re['gender'] = $user->u_sex;
     $user->load('booths');
     $booths = null;
     if (!empty($user->booths)) {
         foreach ($user->booths as $key => $booth) {
             $booths[] = $booth->showInLogin();
         }
     }
     $re['boohts'] = $booths;
     return $re;
 }
Exemplo n.º 3
0
 /**
  * log user in
  * @author Kydz 2015-06-14
  * @return sting user token
  */
 public function login()
 {
     $this->baseValidate();
     $user = User::where('u_mobile', '=', $this->u_mobile)->where('u_status', '=', 1)->first();
     if (!isset($user->u_id)) {
         throw new Exception("请求的用户不可用", 3002);
     }
     if (!Hash::check($this->u_password, $user->u_password)) {
         throw new Exception("密码错误", 3002);
     } else {
         $re = [];
         $re['token'] = $user->u_token;
         $now = new Datetime();
         $now->modify('+ 30 days');
         $re['expire'] = $now->format('Y-m-d H:i:s');
         $re['invite_code'] = $user->u_invite_code;
         $re['id'] = $user->u_id;
         $re['name'] = $user->u_name;
         $re['mobile'] = $user->u_mobile;
         $re['nickname'] = $user->u_nickname;
         $re['is_verified'] = $user->u_is_verified;
         $re['head_img'] = $user->getHeadImg();
         $re['biograph'] = $user->u_biograph;
         $school = DicSchool::find($user->u_school_id);
         if (empty($school)) {
             $re['city'] = null;
             $re['school'] = null;
         } else {
             $re['city'] = DicCity::where('c_id', '=', $school->t_city)->where('c_province_id', '=', $school->t_province)->first()->showInList();
             $re['school'] = $school->showInList();
         }
         $re['gender'] = $user->u_sex;
         $user->load('booths');
         $booths = null;
         if (!empty($user->booths)) {
             foreach ($user->booths as $key => $booth) {
                 $booths[] = $booth->showInLogin();
             }
         }
         $re['boohts'] = $booths;
         $re['import_type'] = 'phone';
         $user->save();
         return $re;
     }
 }