mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2026-03-03 00:47:02 +00:00
Fixes for entity failed to send object
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user