Fixes for entity failed to send object

This commit is contained in:
David Bomba
2026-01-23 13:56:24 +11:00
parent e51a3c4b31
commit cd7a688704

View File

@@ -46,6 +46,31 @@ class EntityFailedSendObject
{
$this->invitation = $invitation;
$this->entity_type = $entity_type;
// Load relationships if they're not already loaded (e.g., when withoutRelations() was called)
if (!$invitation->relationLoaded('contact')) {
$invitation->load('contact');
}
if (!$invitation->relationLoaded('company')) {
$invitation->load('company.account');
} else {
// If company is loaded, ensure account is also loaded
if ($invitation->company && !$invitation->company->relationLoaded('account')) {
$invitation->company->load('account');
}
}
if (!$invitation->relationLoaded($entity_type)) {
$invitation->load([$entity_type => function ($query) {
$query->with('client');
}]);
} else {
// If entity is loaded, ensure client is also loaded
$entity = $invitation->{$entity_type};
if ($entity && !$entity->relationLoaded('client')) {
$entity->load('client');
}
}
$this->entity = $invitation->{$entity_type};
$this->contact = $invitation->contact;
$this->company = $invitation->company;