Skip to content

Commit 012a309

Browse files
authored
Fix Call to a member function only() on null error
If a participant is deleted and you try to get the messages in a conversation you will get an error when trying to get the sender attribute. This fixes it.
1 parent 13dd521 commit 012a309

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Models/Message.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public function participation()
4747
public function getSenderAttribute()
4848
{
4949
$participantModel = $this->participation->messageable;
50+
51+
if (!isset($participantModel)){
52+
return null;
53+
}
5054

5155
if (method_exists($participantModel, 'getParticipantDetails')) {
5256
return $participantModel->getParticipantDetails();

0 commit comments

Comments
 (0)