This commit is contained in:
Simon Pocrnjič 2024-11-19 19:50:47 +01:00
parent d2f916bb79
commit e804d6f4d5
2 changed files with 12 additions and 8 deletions

View File

@ -41,9 +41,12 @@ public function toSearchableArray(): array
'phones' => $this->person->phones
];*/
return [
'person' => $this->person->toArray()
];
$this->loadMissing('person');
$array = $this->toArray();
$array['person'] = $this->person ? $this->person->toArray() : [];
return $array;
}

View File

@ -34,11 +34,12 @@ protected function makeAllSearchableUsing(Builder $query): Builder
public function toSearchableArray(): array
{
return [
'person' => $this->person,
'addresses' => $this->person->addresses,
'phones' => $this->person->phones
];
$this->loadMissing('person');
$array = $this->toArray();
$array['person'] = $this->person ? $this->person->toArray() : [];
return $array;
}
public function client(): BelongsTo