nahid / talk

Talk is a real-time users messaging and chatting system for Laravel.
MIT License
1.61k stars 327 forks source link

getMessagesByUserId , offset & $take not working #59

Closed Coldzer0 closed 7 years ago

Coldzer0 commented 7 years ago

i'm using the test example and i try to edit

i'v 122 message in the db $conversations = Talk::getMessagesByUserId($id); to $conversations = Talk::getMessagesByUserId($id,0,10);

it return 122 every time

i think the main problem is here $this->makeMessageCollection($conversations);

$collection->messages = $conversations->messages;

this call the messages relation without any limit .

nahid commented 7 years ago

@Coldzer0 $this->makeMessageCollection() get data from here https://github.com/nahid/talk/blob/master/src/Conversations/ConversationRepository.php#L152 and here I write pagination code

Coldzer0 commented 7 years ago

try it it's not working :D or give me an example please , test it .

the main problem is $collection->messages = $conversations->messages;

cuz it return all the messages for the conversations .

thanks

nahid commented 7 years ago

@Coldzer0 thank you for finding out this problem. I issue was solved. Now you can use paginate with offset and take.

To use this update please use dev-master

boofman15 commented 7 years ago

I just upgraded from Laravel 5.0 to 5.4. When I go to see messages between two different users, no messages come up. After debugging, I have found that if I comment out line 164 in ConversationRepository.php ($query->offset($offset)->take($take);) then messages are displayed fine.

Are you sure eager loading with limits is working as you expected? Thanks for the help!

fabiojundev commented 6 years ago

I have the same problem as @boofman15, using Laravel 5.6.