public function getIndex() { $conversations = Conversation::with('lastMessage', 'lastMessage.user')->withUser(Auth::id())->get()->sortBy(function ($conversation) { return $conversation->lastMessage->created_at; })->reverse(); return $conversations; }
private function getConversations() { return Conversation::with('lastMessage')->withUser(Auth::id())->get()->sortBy(function ($conversation) { return $conversation->lastMessage->created_at; })->reverse(); }