Skip to content

Commit

Permalink
Merge pull request #753 from bakaphp/refact-soft-delete-search
Browse files Browse the repository at this point in the history
 fix
  • Loading branch information
kaioken authored Dec 24, 2023
2 parents 10e2f2e + 1e23253 commit 4b276e3
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/Kanvas/Traits/SearchableDynamicIndexTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ abstract public function shouldBeSearchable(): bool;
*/
public function searchableAs(): string
{
$appId = $this->apps_id ?? app(Apps::class)->getId();
$record = null;
$record = $this->find($this->id);
$appId = $this->apps_id == null && isset($record->apps_id) ? $record->apps_id : app(Apps::class)->getId();
$companyId = $this->companies_id ?? null;

if (! isset($this->companies_id)) {
$record = $this->find($this->id);
$appId = $record instanceof self ? $record->apps_id : $appId;
if ($this->searchableDeleteRecord()) {
$companyId = $record instanceof self ? $record->companies_id : $this->companies_id;
}

Expand All @@ -56,11 +54,8 @@ public function searchableDeleteRecord(): bool

public function appSearchableIndex(): void
{
$appId = $this->apps_id ?? app(Apps::class)->getId();
if (! isset($this->companies_id)) {
$record = $this->find($this->id);
$appId = $record instanceof self ? $record->apps_id : $appId;
}
$record = $this->find($this->id);
$appId = $this->apps_id == null && isset($record->apps_id) ? $record->apps_id : app(Apps::class)->getId();

$indexName = self::$overWriteSearchIndex !== null
? self::$overWriteSearchIndex
Expand Down

0 comments on commit 4b276e3

Please sign in to comment.