/** * 获得用户等级 * * @author yangyifan <*****@*****.**> */ public static function DegreeOfCompletion($user_id = null) { $user_id = self::getUserId($user_id); //获得用户详细信息 $data = DB::table('user_info')->where('id', '=', $user_id)->first(); $data->user_profile = ProfileModel::getUserOtherProfile($user_id); $total = 0; if (!empty($data->mobile)) { $total += 10; } if (!empty($data->user_profile->truename)) { $total += 10; } if (!empty($data->sex)) { $total += 10; } if (!empty($data->user_profile->id_card)) { $total += 10; } if (!empty($data->user_profile->marriage)) { $total += 10; } if ($total >= 50) { Session::put('user_info.level', '2'); } else { Session::put('user_info.level', '1'); } Session::save(); }
/** * 组合私信内容 * * @param $data * @return mixed * @author yangyifan <*****@*****.**> */ private static function mergeLetter($data) { if (!empty($data)) { foreach ($data as $letter) { $letter->user_info = ProfileModel::getUserSimpleInfo($letter->user_info_id); } } return $data; }
/** * 帖子详情 * * @return \Illuminate\View\View * @author yangyifan <*****@*****.**> */ public function getInfo(Request $request, $id) { //获得帖子内容 $forum_info = ForumModel::getInfo($id); if (empty($forum_info)) { return redirect()->action('Home\\ForumController@getIndex'); } return view('home.forum.info', ['user_profile' => ProfileModel::getUserProfile($forum_info->user_info_id), 'data' => $forum_info, 'title' => '论坛-' . $forum_info->title, 'keywords' => '论坛-' . $forum_info->title, 'description' => '论坛-' . $forum_info->title]); }
/** * 检测用户等级 * * @return bool * @author yangyifan <*****@*****.**> */ private function checkAccess() { $allow_action = ['App\\Http\\Controllers\\User\\ProfileController@getProfile', 'App\\Http\\Controllers\\User\\ProfileController@postProfile']; //如果当前角色等级不够,则不允许访问当前页面 if (!in_array(Route::currentRouteAction(), $allow_action) && ProfileModel::checkUserLevel() == false) { if (Request::method() == 'POST') { $this->response(400, trans('response.user_access_error')); } else { header('location:' . action('Home\\IndexController@getIndex')); die; } } }
/** * 更新用户密码 * * @param Passwordequest $request * @author yangyifan <*****@*****.**> */ public function postUpdatePassword(Passwordequest $request) { $status = ProfileModel::updatePassword($request->only('old_password', 'password')); if ($status === true) { $this->response(200, trans('response.update_user_password_success')); } else { if ($status == -1) { $this->response(400, trans('response.old_password_error')); } else { if ($status === false) { $this->response(400, trans('response.update_user_password_error')); } } } }
/** * 获得帖子评论信息 * * @param $id * @return mixed * @author yangyifan <*****@*****.**> */ private static function getForumComment($id) { $comment_list = DB::table('forum_comment')->where('forum_id', '=', $id)->where('status', '=', '1')->orderBy('id', 'DESC')->paginate(config('config.forum_comment_page_limit')); if (!empty($comment_list)) { foreach ($comment_list as $comment) { $comment->user_info = ProfileModel::getUserSimpleInfo($comment->user_info_id); } } return $comment_list; }