Skip to content

Commit

Permalink
fix: notification subject discussion eager loading fails (#3788)
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 authored Apr 16, 2023
1 parent b89a01c commit 7a6d477
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,16 @@ private function loadSubjectDiscussions(array $notifications)
$ids = [];

foreach ($notifications as $notification) {
if ($notification->subject && property_exists($notification->subject, 'discussion_id')) {
$ids[] = $notification->subject->discussion_id;
if ($notification->subject && ($discussionId = $notification->subject->getAttribute('discussion_id'))) {
$ids[] = $discussionId;
}
}

$discussions = Discussion::query()->find(array_unique($ids));

foreach ($notifications as $notification) {
if ($notification->subject && property_exists($notification->subject, 'discussion_id')) {
$notification->subject->setRelation('discussion', $discussions->find($notification->subject->discussion_id));
if ($notification->subject && ($discussionId = $notification->subject->getAttribute('discussion_id'))) {
$notification->subject->setRelation('discussion', $discussions->find($discussionId));
}
}
}
Expand Down

0 comments on commit 7a6d477

Please sign in to comment.