Example #1
0
 /**
  * Show all of the message threads to the user
  *
  * @return mixed
  */
 public function index()
 {
     $currentUserId = Auth::user()->id;
     // All threads that user is participating in
     $threads = Thread::forUser($currentUserId)->get();
     return view('messenger.index', compact('threads', 'currentUserId'));
 }
Example #2
0
 /**
  * 获取用户消息列表
  */
 public function index()
 {
     $customer_id = $this->user()->id;
     $threads = Thread::forUser($customer_id)->get();
     foreach ($threads as $thread) {
         $message = $thread->messages()->latest()->get();
         $thread->message = $message[0]['body'];
     }
     return return_rest('1', compact('threads'), '消息列表');
 }
 public function getThreads()
 {
     $currentUserId = Auth::user()->id;
     // All threads, ignore deleted/archived participants
     //$threads = Thread::getAllLatest()->get();
     // All threads that user is participating in
     $threads = Thread::forUser($currentUserId)->latest('updated_at')->get();
     // All threads that user is participating in, with new messages
     // $threads = Thread::forUserWithNewMessages($currentUserId)->latest('updated_at')->get();
     return view('messages.index', ['page' => 'message', 'threads' => $threads, 'currentUserId' => $currentUserId]);
 }
 /**
  * Show all of the message threads to the user.
  *
  * @return mixed
  */
 public function index()
 {
     $currentUserId = Authorizer::getResourceOwnerId();
     // All threads, ignore deleted/archived participants
     //   $threads = Thread::getAllLatest()->get();
     // All threads that user is participating in
     $threads = Thread::forUser($currentUserId)->latest('updated_at')->get();
     // All threads that user is participating in, with new messages
     //$threads = Thread::forUserWithNewMessages($currentUserId)->latest('updated_at')->get();
     return compact('threads', 'currentUserId');
 }
 /**
  * Show all of the message threads to the user
  *
  * @return mixed
  */
 public function index()
 {
     $currentUserId = Auth::user()->id;
     // All threads, ignore deleted/archived participants
     //$threads = Thread::getAllLatest()->get();
     // All threads that user is participating in
     $threads = Thread::forUser($currentUserId)->latest('updated_at')->get();
     // All threads that user is participating in, with new messages
     // $threads = Thread::forUserWithNewMessages($currentUserId)->latest('updated_at')->get();
     return View::make('messenger.index', compact('threads', 'currentUserId'));
 }
Example #6
0
 /**
  * Show all of the message threads to the user
  *
  * @return mixed
  */
 public function index()
 {
     $currentUserId = Auth::user()->id;
     // All threads, ignore deleted/archived participants
     $threads = Thread::forUser($currentUserId)->paginate(3);
     $threadLinks = $threads->render();
     // All threads that user is participating in
     // $threads = Thread::forUser($currentUserId);
     // All threads that user is participating in, with new messages
     // $threads = Thread::forUserWithNewMessages($currentUserId);
     return view('core.conversations.index', compact('threads', 'currentUserId', 'threadLinks'));
 }
Example #7
0
 /**
  * Get signed in user's profile.
  */
 public function getUser(Request $request)
 {
     $user = User::find($request['user']['sub']);
     $user->roles = $user->roles()->get();
     $user->isAdmin = $user->hasRole('admin');
     $user->profile = $user->profile;
     $user->locations = $user->locations;
     $user->notifications = $user->getNotifications();
     $user->notificationsNotRead = $user->countNotificationsNotRead();
     $threads = Thread::forUser($user->id)->latest('updated_at')->get();
     $user->threads = $threads;
     $roles = Role::all(['id', 'display_name']);
     $activities = ActivityModel::where('user_id', $user->id)->get();
     return Response::json(['user' => $user, 'roles' => $roles, 'activities' => $activities]);
 }
 /**
  * Show all of the message threads associated with the user
  *
  * Example URL: GET /api/v1/messages?api_key=30ce6864e2589b01bc002b03aa6a7923&per_page=10&page=2
  *
  * @param ThreadTransformer $threadTransformer
  * @return mixed
  */
 public function index(ThreadTransformer $threadTransformer)
 {
     $userId = $this->user->id;
     $perPage = (int) Input::get('per_page', 25);
     // get all of the paginated threads
     $threads = Thread::forUser($userId)->latest('updated_at')->paginate($perPage);
     $threads->setPath(route('messages'));
     $threads->addQuery('api_key', $this->user->api_key);
     $threads->addQuery('per_page', $perPage);
     if ($threads->total() == 0) {
         return $this->respondNotFound('No results returned. Please check back later.');
     }
     // see if the threads have been read by the user
     $threads->each(function ($thread) use($userId) {
         $thread->is_unread = $thread->isUnread($userId);
     });
     $data = $threadTransformer->transformCollection($threads->toArray()['data']);
     $response = ['pagination' => $this->buildPagination($threads), 'data' => $data];
     return $this->respondWithSuccess($response);
 }
 /**
  * Show all of the message threads to the user
  *
  * @return mixed
  */
 public function index()
 {
     $currentUserId = JWTAuth::parseToken()->authenticate()->id;
     // All threads, ignore deleted/archived participants
     //        $threads = Thread::getAllLatest()->get();
     // All threads that user is participating in
     // All threads that user is participating in, with new messages
     $threads = Thread::forUser($currentUserId)->latest('updated_at')->get()->unique();
     $temp = [];
     foreach ($threads as $thread) {
         $message = Thread::findOrFail($thread->id)->messages()->latest()->first();
         $ids = $thread->participantsUserIds();
         $temp2 = null;
         foreach ($ids as $id) {
             if ($id != $currentUserId) {
                 $temp2 = $id;
             }
         }
         array_push($temp, [$thread, $message->body, User::find($temp2)]);
     }
     return response()->json(['success' => true, 'message' => "Successful", 'threads' => $temp]);
 }
Example #10
0
 /**
  * Retrieves a specific innovation with its related data
  * @param $id
  * @param ConversationRepository $conversationRepository
  * @return \Illuminate\View\View
  */
 public function show($id, ConversationRepository $conversationRepository)
 {
     $innovation = $this->repo->retrieve($id);
     $check_chat = $conversationRepository->chatExists($id);
     $currentUserId = Auth::user()->id;
     $chatWithInnovator = $conversationRepository->checkChatWithInnovator($id);
     $mother = User::where('id', '=', $innovation->moderator_id)->first();
     $users = User::where('userCategory', '=', 3)->get();
     $investors = User::where('userCategory', '=', 2)->get();
     // All threads that user is participating in
     $threads = Thread::forUser($currentUserId)->where('innovation_id', '=', $id)->get();
     $threads_count = $threads->count();
     if (\Auth::user()->isInvestor()) {
         if (Thread::where('innovation_id', '=', $id)->where('user_id', '=', \Auth::user()->id)->exists() == true) {
             $thread = Thread::where('innovation_id', '=', $id)->where('user_id', '=', \Auth::user()->id)->first();
         }
     }
     if (\Auth::user()->isMother()) {
         if (Thread::where('innovation_id', '=', $id)->where('user_id', '=', \Auth::user()->id)->exists() == true) {
             $thread_mother = Thread::where('innovation_id', '=', $id)->where('user_id', '=', \Auth::user()->id)->first();
         } else {
             $thread_mother = null;
         }
     }
     $funds = $this->repo->getPortfolio($id);
     $totalNeeded = $this->repo->getInnovationFund($id);
     return view('innovation.show', compact('totalNeeded', 'funds', 'thread_mother', 'thread', 'investors', 'mother', 'users', 'chatWithInnovator', 'innovation', 'id', 'check_chat', 'message', 'threads', 'threads_count', 'currentUserId'));
 }
Example #11
0
 /**
  * Get a user's conversations.
  *
  * @return Thread
  */
 public function getConversations()
 {
     return Thread::forUser($this->id);
 }
 /**
  * Show all of the message threads to the user.
  *
  * @return mixed
  */
 public function index()
 {
     $currentUserId = Auth::user()->id;
     $threads = Thread::forUser($currentUserId)->latest('updated_at')->get();
     return view('messenger.index', compact('threads'));
 }