public function index() { //总访问量 $visits = \Cache::get('visits', 0); //今日注册用户 $todayUsers = User::today()->count('user_id'); //总用户数 $totalUsers = User::count('user_id'); //管理员聊天记录 $chatMessages = AdminMessage::with('admin')->limit(10)->oldest()->get(); //最新留言 $guestBook = GuestBook::with('user')->limit(10)->oldest()->get(); //最新注册用户 $users = User::limit(24)->oldest()->get(); //最新评论 $comments = Comment::limit(10)->oldest()->get(); // 总会员数量/待审核会员/普通会员/高端会员 $user_all_num = User::count('user_id'); $user_shenhe_num = User::status(\App\Enum\User::STATUS_CHECK)->count('user_id'); $user_level1_num = User::level(\App\Enum\User::LEVEL_1)->count('user_id'); $user_level3_num = User::level(\App\Enum\User::LEVEL_3)->count('user_id'); // 自我介绍待审核数量 $user_info_num = UserInfo::where('introduce_status', \App\Enum\User::INTRODUCE_CHECK)->count('user_id'); // 会员相片审核数量 $user_gallery_num = DB::table('user_gallery')->where('status', '待审核')->where('image_url', '!=', '')->count('photo_id'); // 文章数量 $article_num = DB::table('articles')->count('article_id'); $res = array('user_all_num' => $user_all_num, 'user_shenhe_num' => $user_shenhe_num, 'user_level1_num' => $user_level1_num, 'user_level3_num' => $user_level3_num, 'user_info_num' => $user_info_num, 'user_gallery_num' => $user_gallery_num, 'article_num' => $article_num); return $this->view('index', $res); // return $this->view('index')->with('visits', $visits)->with('todayUsers', $todayUsers)->with('totalUsers', // $totalUsers)->with('chatMessages', $chatMessages)->with('guestBook', $guestBook)->with('users', // $users)->with('comments', $comments); }
/** * * @SWG\Api( * path="/user_info", * description="用户信息(新20160304)", * @SWG\Operation( * method="POST", summary="添加,修改用户信息", notes="添加,修改用户信息", * @SWG\ResponseMessage(code=0, message="成功"), * @SWG\Parameter( * name="user_info", * description="用户id", * paramType="body", * required=true, * type="UserInfo" * ) * ) * ) */ public function store(Request $request) { $response = new BaseResponse(); $content = json_decode($request->getContent(false)); if (!isset($content->id)) { $response->Code = BaseResponse::CODE_ERROR_CHECK; $response->Message = '用户id不能为空'; return $response->toJson(); } $userId = $content->id; $userAccount = $content->user_account; $nickName = $content->nick_name; $headIcon = $content->head_icon; $userInfo = UserInfo::findOrNew($userId); $userInfo->id = $userId; $userInfo->user_account = $userAccount; $userInfo->nick_name = $nickName; $userInfo->head_icon = $headIcon; $userInfo->save(); return $response->toJson(); }
public function getUserFans() { $request = Request::capture(); $token = $request->input('token'); $userFansId = $request->input('userId'); $userId = AuthController::getUserIdByToken($token); if ($userId == null) { return Utility::response_format(Utility::RESPONSE_CODE_AUTH_ERROR, '', '认证失败'); } if ($userFansId == null) { // 如果参数userId为空 则赋值token身份中的userId $userFansId = $userId; } // token 认证 $result = array(); $userFans = UserAccount::find($userFansId)->userFans; foreach ($userFans as $fans) { $info = UserInfo::where('user_id', $fans->id)->first(); if ($info != null) { array_push($result, $info); } } return $result; }
public function getAnswerDetail() { $request = Request::capture(); $token = $request->input('token'); $answerId = $request->input('answerId'); $userId = AuthController::getUserIdByToken($token); if ($userId == null) { return Utility::response_format(Utility::RESPONSE_CODE_AUTH_ERROR, '', '认证失败'); } if ($answerId == null) { return Utility::response_format(Utility::RESPONSE_CODE_Error, '', 'answerId不能为空'); } $answer = Answer::select('id', 'answer_content', 'answer_time', 'question_id', 'user_id', 'is_resolved')->where('id', $answerId)->first()->toArray(); // print_r($question); // 个人信息 $userInfo = UserInfo::select('user_name', 'head_pic')->where('user_id', $answer['user_id'])->first()->toArray(); $answer = array_merge($answer, $userInfo); // 图片 $picIds = AnswerPictures::select('pic_id')->where('answer_id', $answer['id'])->get()->toArray(); $pics = Picture::whereIn('id', $picIds)->get()->toArray(); $answer = array_merge($answer, ['image' => $pics]); // 评论数 $comments = Comment::where('answer_id', $answer['id'])->count(); $answer = array_merge($answer, ['commentNumber' => $comments]); // 赞数 $upCount = AnswerUp::where('answer_id', $answer['id'])->count(); $answer = array_merge($answer, ['upNumber' => $upCount]); return Utility::response_format(Utility::RESPONSE_CODE_SUCCESS, $answer, '请求成功'); }
public function register() { $request = Request::capture(); $username = $request->input('username'); $password = $request->input('password'); $nickname = $request->input('nickname'); $age = $request->input('age'); $information = $request->input('information'); $location = $request->input('location'); $headPic = $request->input('headPicture'); $homePic = $request->input('homePicture'); if ($username == null || $password == null) { // 账号 密码 不能为空 return Utility::response_format(Utility::RESPONSE_CODE_Error, '', '账号密码不能为空'); } else { if (UserAccount::where('username', $username)->first() != null) { return Utility::response_format(Utility::RESPONSE_CODE_Error, '', '账号已存在'); } else { if (Utility::isValidateUsername($username) == false) { // 用户名无效 } else { if (Utility::isValidatePassword($password) == false) { // 密码无效 } } } } $token = Utility::genToken(); DB::beginTransaction(); try { $user = UserAccount::create(['username' => $username, 'password' => $password, 'token' => $token]); $userInfo = UserInfo::create(['user_name' => $nickname, 'user_age' => $age, 'user_information' => $information, 'user_location' => $location, 'user_id' => $user->id, 'head_pic' => $headPic, 'home_pic' => $homePic]); DB::commit(); $userInfo['token'] = $user->token; $userInfo['tags'] = $user->userTags; return $userInfo; } catch (Exception $e) { DB::rollBack(); return Utility::response_format(Utility::RESPONSE_CODE_DB_ERROR, '', $e->getMessage()); } }
$em->persist($user_info); $em->flush($user_info); $app->response->headers->set('Content-Type', 'application/json'); echo Util::resPonseJson($app, 200, "", array()); exit; } catch (Exception $e) { $app->response->headers->set('Content-Type', 'application/json'); echo Util::resPonseJson($app, 500, "System error.", array()); exit; } exit; }); $app->get('/userinfo/:user_id', $check_auth($em), function ($user_id) use($app, $em) { $user = $em->getRepository('App\\Model\\User')->find($user_id); if (!$user) { $app->response->headers->set('Content-Type', 'application/json'); echo Util::resPonseJson($app, 4004, "User not exists.", array()); exit; } $userInfo = $em->getRepository('App\\Model\\UserInfo')->find($user_id); if (!$userInfo) { $userInfo = new UserInfo(); } $allInfo = array_merge($user->toArray(), $userInfo->toArray()); unset($allInfo['password_hash']); unset($allInfo['payment_password']); unset($allInfo['user_id']); $app->response->headers->set('Content-Type', 'application/json'); echo Util::resPonseJson($app, 200, "", array("user" => $allInfo)); exit; });
public function getRecommend() { $UserInfo = UserInfo::where('introduce_status', '等待审核')->get(); return $this->view('recommend')->with('UserInfo', $UserInfo); }
public function setIntroduceStatus() { $data = $this->request()->all(); try { $userInfo = UserInfo::find($data['user_id']); if (!$userInfo) { return $this->rest()->error('不存在的用户'); } $userInfo->introduce_status = $data['status']; if ($data['status'] == \App\Enum\User::INTRODUCE_OK) { $userInfo->introduce = $userInfo->new_introduce; $userInfo->new_introduce = NULL; } $userInfo->save(); return $this->rest()->success(array(), '操作成功'); } catch (\Exception $e) { return $this->rest()->error($e->getMessage()); } }