Exemplo n.º 1
0
 public function online(FriendRepository $friendRepository)
 {
     $friends = $friendRepository->myFriends();
     $friends = $friends->each(function ($friend, $key) {
         $friend->friend_info->activity;
     });
     return $friends;
 }
Exemplo n.º 2
0
 private function stream($friendship)
 {
     $friendRepository = new FriendRepository();
     $friends = $friendRepository->myFriends();
     $user = Auth::user();
     foreach ($friends as $friend) {
         Stream::create(['user_id' => $friend->friend_info->id, 'edge_ranke' => 0, 'contentable_id' => $friendship->id, 'contentable_type' => 'App\\Friend', 'parentable_id' => $user->id, 'parentable_type' => 'App\\User', 'is_see' => 0]);
     }
     Stream::create(['user_id' => $user->id, 'edge_ranke' => 0, 'contentable_id' => $friendship->id, 'contentable_type' => 'App\\Friend', 'parentable_id' => $user->id, 'parentable_type' => 'App\\User', 'is_see' => 1]);
 }
Exemplo n.º 3
0
 private function stream($post)
 {
     $friendRepository = new FriendRepository();
     $friends = $friendRepository->myFriends();
     $user = Auth::user();
     foreach ($friends as $friend) {
         Stream::create(['user_id' => $friend->friend_info->id, 'edge_ranke' => 0, 'contentable_id' => $post->id, 'contentable_type' => 'App\\Post', 'parentable_id' => $user->id, 'parentable_type' => 'App\\User', 'is_see' => 0]);
         Event::fire(new Notification($friend->friend_info->id, 'App\\Post', $post));
     }
     Stream::create(['user_id' => $user->id, 'edge_ranke' => 0, 'contentable_id' => $post->id, 'contentable_type' => 'App\\Post', 'parentable_id' => $user->id, 'parentable_type' => 'App\\User', 'is_see' => 1]);
 }
Exemplo n.º 4
0
 public function index(FriendRepository $friendRepository, ChatRepository $chatRepository, User $holder)
 {
     $user = Auth::user();
     if (!empty($holder->id)) {
         $histories = $chatRepository->historyCollection($holder->id)->get();
         Event::fire(new seenMessage($holder->id));
         MessageUser::where('parentable_type', 'App\\User')->where('parentable_id', $holder)->where('user_id', $user->id)->where('status', 0)->update(['status' => 1]);
     } else {
         $histories = [];
     }
     $friends = $friendRepository->myFriends();
     $chats = $chatRepository->myChats();
     $friends = $friends->each(function ($friend, $key) use($chatRepository) {
         $chatRepository->latest($friend->friend_info->id);
         $friend->latestMessage = $chatRepository->latestMessage();
         $friend->latestCreatedAt = $chatRepository->latestCreatedAt();
         $friend->latestHumanCreatedAt = jDate::forge($friend->latestCreatedAt)->ago();
         $friend->newMessagesCount = $chatRepository->newMessagesCount();
     });
     $friends = $friends->sortByDesc('latestCreatedAt');
     return view('chat.index', compact('user', 'friends', 'chatRepository', 'histories', 'holder', 'chats'))->with(['title' => 'گفتگو']);
 }