Пример #1
0
 public function toAgree(Request $request)
 {
     if (Auth::check()) {
         $all = $request->all();
         $interest = new Interest_relations();
         $interest->updateInterest($all['from_id'], $request->user()->id, $all['type']);
         return $this->_returnMessage('success', 200, $all['signal']);
     } else {
         return redirect()->guest('login');
     }
 }
Пример #2
0
 public function showSource($id, Request $request)
 {
     if (Auth::check()) {
         //获取用户profile
         $result = $this->profile->getInfo($id);
         if (empty($result)) {
             $this->profile->create(['user_id' => $id]);
         }
         $user_info = $this->user->getSetting($id);
         if (empty($user_info->avatar)) {
             $user_info->avatar = AVATAR;
         }
         //默认头像
         $user_info->age = isset($user_info->age) ? unserialize(AGE)[$user_info->age] : '';
         $user_info->place = isset($user_info->place) ? unserialize(PLACE)[$user_info->place] : '';
         $user_info->email = !empty($user_info->email) ? $user_info->email : $user_info->regist_email;
         $interest = new Interest_relations();
         $result = $interest->getInterest($request->user()->id, $id, 1);
         if (empty($result) || $result->agree == 0) {
             $user_info->email = $this->hide($user_info->email);
             $user_info->phone = $this->hide($user_info->phone);
         } else {
             $result_prof = $interest->getInterest($request->user()->id, $id, 2);
             if (empty($result_prof) || $result_prof->agree == 0) {
                 $user_info->email = $this->hide($user_info->email);
                 $user_info->phone = $this->hide($user_info->phone);
             }
         }
         $user_info->id = 1;
         //没有编辑按钮
         $project = new Project();
         $user_info->project = 0;
         //没有该user_id的项目
         $user_info->proj_id = $project->getId($id);
         if (!empty($user_info->proj_id)) {
             $user_info->project = 1;
             //有
             $user_info->proj_id = $user_info->proj_id->id;
         }
         return view('users.setting')->with('user_info', $user_info);
     } else {
         return redirect()->guest('login');
     }
 }
Пример #3
0
 public function toFocus(Request $request)
 {
     if (Auth::check()) {
         $from_id = $request->user()->id;
         //关注者
         $all = $request->all();
         $to_id = $this->project->getUserId($all['item_id'])->user_id;
         $user = new User();
         $userInfo = $user->getEmail($to_id);
         switch ($all['type']) {
             case 1:
                 if ($from_id == $to_id) {
                     return $this->_returnMessage('不能关注自己的项目', 102);
                 }
                 $focus = new User_relation();
                 $focus_result = $focus->getFocus($from_id, $all['item_id'], 1);
                 if (empty($focus_result)) {
                     $insert = $focus->insertFocus($from_id, $to_id, $all['item_id'], 1);
                     if ($insert != 1) {
                         return $this->_returnMessage('插入失败', 101);
                     } else {
                         $update = $this->project->updateFocus($all['item_id']);
                         if ($update != 1) {
                             return $this->_returnMessage('更新失败', 101);
                         }
                         $mes = new Message();
                         $mes->insertMes($from_id, $to_id, $all['item_id'], 1, 1);
                         $data = ['email' => $userInfo->email, 'name' => $userInfo->name];
                         Mail::send('activemail', $data, function ($message) use($data) {
                             $message->to($data['email'], $data['name'])->subject('【拾】有人关注你的项目~,请登录网站进行查看哦!~');
                         });
                         return $this->_returnMessage('关注成功', 200);
                     }
                 } else {
                     return $this->_returnMessage('已关注过', 102);
                 }
                 break;
             case 2:
                 $like = new Like_relations();
                 $like_result = $like->getLike($from_id, $all['item_id'], 1);
                 if (empty($like_result)) {
                     //插入关注记录
                     $insert = $like->insertLike($from_id, $to_id, $all['item_id'], 1);
                     if ($insert != 1) {
                         return $this->_returnMessage('插入失败', 101);
                     } else {
                         $update = $this->project->updateLike($all['item_id']);
                         if ($update != 1) {
                             return $this->_returnMessage('更新失败', 101);
                         }
                         //                            $mes = new Message();
                         //                            $mes->insertMes($from_id,$to_id,$all['item_id'],2,1);
                         return $this->_returnMessage('点赞成功', 201);
                     }
                 } else {
                     return $this->_returnMessage('已赞', 102);
                 }
                 break;
             case 3:
                 if ($from_id == $to_id) {
                     return $this->_returnMessage('不能向自己的项目发送感兴趣', 102);
                 }
                 $interest = new Interest_relations();
                 $interest_result = $interest->getInterest($from_id, $all['item_id'], 1);
                 if (empty($interest_result)) {
                     $insert = $interest->insertInterest($from_id, $to_id, $all['item_id'], 1);
                     if ($insert != 1) {
                         return $this->_returnMessage('插入失败', 101);
                     } else {
                         $update = $this->project->updateInterest($all['item_id']);
                         if ($update != 1) {
                             return $this->_returnMessage('更新失败', 101);
                         }
                         $mes = new Message();
                         $mes->insertMes($from_id, $to_id, $all['item_id'], 3, 1);
                         $data = ['email' => $userInfo->email, 'name' => $userInfo->name];
                         Mail::send('activemail', $data, function ($message) use($data) {
                             $message->to($data['email'], $data['name'])->subject('【拾】有人对你的项目感兴趣~,请登录网站进行查看哦!~');
                         });
                         return $this->_returnMessage('感兴趣成功', 202);
                     }
                 } else {
                     return $this->_returnMessage('已感兴趣', 102);
                 }
             default:
                 return $this->_returnMessage('参数错误', 101);
                 break;
         }
     } else {
         return redirect()->guest('login');
     }
 }