public function read() { $thread = Thread::find($this->request->get('id')); if (!$thread) { return return_rest('0', compact('count'), '该消息不存在'); } $thread->markAsRead($this->user()->id); return return_rest('1', compact('count'), '已读消息'); }
public function update() { //获取投资人公司信息 $investCompany = $this->investCompany->find($this->user()->company_id); //判断该用户是否有投资公司 if (is_null($investCompany)) { return return_rest('0', '', '更新失败 该用户没有投资公司'); } $investCompany->fill($this->request->input()); if ($investCompany->save()) { return return_rest('1', '', '更新成功'); } return return_rest('0', '', '更新失败'); }
/** * 查看用户审核状态 */ public function typeState() { $name = $this->user()->name; $user_name = $this->user()->user_name; $type_state = $this->user()->type_state; $avatar = $this->user()->avatar; return return_rest('1', compact('name', 'user_name', 'type_state', 'avatar'), '获取用户审核状态'); }
/** * 获取投资轮次 */ public function round() { $round = InvestRoundConfig::get()->toArray(); return return_rest('1', compact('round'), '投资轮次列表'); }
/** * 约谈操作 */ public function interviewDo() { $id = $this->request->get('id'); $state = $this->request->get('state'); $interview = Interview::find($id); $interview->state = $state; if ($interview->save()) { return return_rest('1', '', '操作成功'); } return return_rest('0', '', '操作失败'); }
/** * 验证验证码 */ public function checkVerify() { $token = $this->request->get('smsToken'); $validator = \Validator::make($this->request->all(), ['mobile' => "required|confirm_mobile_not_change:{$token}", 'verifyCode' => "required|verify_code:{$token}|confirm_mobile_rule:mobile_required,{$token}"], ['verifyCode.required' => '请输入短信验证码', 'verify_code' => '验证码错误', 'confirm_mobile_not_change' => '当前手机号码与发送号码不符', 'confirm_mobile_rule' => '验证码验证错误']); $messages = $validator->messages(); if ($messages->has('mobile')) { $mobiles_rule = $messages->get('mobile'); foreach ($mobiles_rule as $mobile_rule) { if ($mobile_rule == '当前手机号码与发送号码不符') { return return_rest('0', '', '当前手机号码与发送号码不符'); } } } if ($messages->has('verifyCode')) { $verifyCodes = $messages->get('verifyCode'); foreach ($verifyCodes as $verifyCode) { if ($verifyCode == '请输入短信验证码') { return return_rest('0', '', '请输入短信验证码'); } if ($verifyCode == '验证码错误') { return return_rest('0', '', '验证码错误'); } if ($verifyCode == '验证码验证错误') { return return_rest('0', '', '验证码验证错误'); } } } return return_rest('1', '', '验证成功'); }
/** * 添加文章评论 */ public function addComment() { //获取活动id $id = $this->request->get('id'); //获取评论内容 $content = $this->request->get('content'); //增加评论 $comment = new ArticleComment(); $comment->article_id = $id; $comment->content = $content; $comment->customer_id = $this->user()->id; $comment->customer_name = $this->user()->name; $comment->customer_avatar = $this->user()->avatar; //判断回复用户 if ($reply_customer_id = $this->request->get('reply_customer_id')) { //获取用户信息 $reply_customer = Customer::find($reply_customer_id); if (!$reply_customer) { return return_rest('0', '', '评论添加失败'); } $comment->reply_customer_id = $reply_customer_id; $comment->reply_customer_name = $reply_customer->name; } if ($comment->save()) { //对文章进行+1的评论 $this->article->find($id)->increment('comments'); //获取评论列表c return return_rest('1', '', '评论添加成功'); } return return_rest('0', '', '评论添加失败'); }
/** * 获取领域详情 */ public function fieldDetail($id) { $subField = $this->model_field->select('id', 'name')->where('parent', $id)->get(); return return_rest('1', compact('subField'), '行业子集菜单'); }
/** * 获取用户报名活动列表 */ public function applyList() { $per_page = 15; if ($this->request->has('per_page')) { $per_page = $this->request->get('per_page'); } //获取活动id $applies = DB::table('activity_customer_apply')->select('activity_id')->where('customer_id', $this->user()->id)->orderBy('id', 'desc')->get(); $aid = array(); foreach ($applies as $apply) { $aid[] = $apply->activity_id; } //获取活动 $applyList = $this->activity->select('id', 'image', 'brief', 'title', 'created_at', 'begin_at', 'end_at')->whereIn('id', $aid)->orderBy('id', 'desc')->paginate($per_page); $applyList = $applyList->toArray(); if ($applyList) { return return_rest('1', compact('applyList'), '获取列表成功'); } return return_rest('1', "", '用户暂未关注活动'); }
public function position() { $position = DB::table('company_position')->select('id', 'name')->get(); return return_rest('1', compact('position'), '职位列表'); }
public function avatar() { //验证数据 $validator = \Validator::make($this->request->all(), ['avatar' => 'required'], ['avatar.required' => '图片没有上传']); if ($validator->fails()) { return $this->errorBadRequest($validator->messages()); } //TODO 获取手机号码 $customer = $this->user(); try { $file = $this->request->file('avatar'); // $fileName = $this->avatar_path.$customer->mobile.'.'.$file->getClientOriginalExtension(); $fileName = $this->avatar_path . $customer->mobile . '.jpg'; $qnName = $customer->mobile . '.jpg'; \Image::make($file)->save($fileName); //上传图片至七牛 if ($this->disk->put($qnName, fopen($fileName, 'r'))) { //获取图片地址 $imgUrl = $this->disk->downloadUrl($qnName); // //更新七牛缓存 // $auth = new Auth(config('filesystems.disks.qiniu.access_key'),config('filesystems.disks.qiniu.secret_key')); // $url = "http://fusion.qiniuapi.com/refresh"; // $token = $auth->signRequest($url, null); // $client = new Client(); // $urls = array('urls' => array($imgUrl)); // $result = $client->request('POST',$url,[ // 'headers' => [ // 'Content-Type' => 'application/json', // 'Authorization' => "QBox $token", // ], // 'body' => json_encode($urls) // ]); //添加进入数据库 $customer->avatar = $imgUrl; $customer->save(); return return_rest('1', compact('imgUrl'), '头像上传成功'); } return return_rest('0', '', '头像上传失败'); } catch (\Exception $e) { //图片上传失败 return return_rest('0', '', $e->getMessage()); } }
/** * 昵称 type */ public function signup() { $token = $this->request->get('smsToken'); $validator = \Validator::make($this->request->all(), ['user_name' => 'required|between:4,12|unique:customers|Regex:/^[a-z0-9]{4,12}$/', 'mobile' => "required|confirm_mobile_not_change:{$token}", 'password' => 'required', 'verifyCode' => "required|verify_code:{$token}|confirm_mobile_rule:mobile_required,{$token}"], ['verifyCode.required' => '请输入短信验证码', 'verify_code' => '验证码错误', 'confirm_mobile_not_change' => '当前手机号码与发送号码不符', 'confirm_mobile_rule' => '验证码验证错误', 'user_name.unique' => '用户名已注册', 'user_name.regex' => '用户名必须为小写字母或数字', 'user_name.between' => '用户名必须为4-12位']); $messages = $validator->messages(); if ($messages->has('mobile')) { $mobiles_rule = $messages->get('mobile'); foreach ($mobiles_rule as $mobile_rule) { if ($mobile_rule == '当前手机号码与发送号码不符') { return return_rest('0', '', '当前手机号码与发送号码不符'); } } } if ($messages->has('verifyCode')) { $verifyCodes = $messages->get('verifyCode'); foreach ($verifyCodes as $verifyCode) { if ($verifyCode == '请输入短信验证码') { return return_rest('0', '', '请输入短信验证码'); } if ($verifyCode == '验证码错误') { return return_rest('0', '', '验证码错误'); } if ($verifyCode == '验证码验证错误') { return return_rest('0', '', '验证码验证错误'); } } } if ($messages->has('password')) { return return_rest('0', '', '请输入密码'); } if ($messages->has('user_name')) { if ($mobile_rule == '用户名已注册') { return return_rest('0', '', '用户名已注册'); } if ($mobile_rule == '用户名必须为小写字母或数字') { return return_rest('0', '', '用户名必须为小写字母或数字'); } if ($mobile_rule == '用户名必须为4-12位') { return return_rest('0', '', '用户名必须为4-12位'); } } //增加环信注册 失败返回false $easemob = Easemob::user_register($this->request->get('user_name'), $this->request->get('password')); //TODO if (isset($easemob['mobile'])) { return return_rest('0', '', '该用户已注册环信'); } //设置用户相关信息 $mobile = $this->request->get('mobile'); $password = $this->request->get('password'); //TODO 用户类型 设置默认为3游客 1为创业者2为投资人 $type = $this->request->has('type') ? $this->request->get('type') : 3; //TODO 其他信息 $customer = new Customer(); $customer->user_name = $this->request->get('user_name'); $customer->mobile = $mobile; $customer->password = bcrypt($password); $customer->type = $type; $customer->avatar = 'http://image.haihespace.com/default/avatar/avatar.jpg'; if ($customer->save()) { // 用户注册事件 $token = \JWTAuth::fromUser($customer); //为用户生成头像 // $img = Image::make('uploads/avatars/avatar.jpg'); // $img->save('uploads/avatars/'.$mobile.'.jpg'); return return_rest('1', compact('token', 'customer')); } $this->errorBadRequest(return_rest('0', '', '操作失败')); }