Skip to content

Commit 0e45a3b

Browse files
committed
Fix softdelete handling.
1 parent 4a3cf53 commit 0e45a3b

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/PostgresEngine.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,16 @@ protected function performSearch(Builder $builder, ?int $perPage = 0, int $page
372372

373373
// Apply where clauses that were set on the builder instance if any
374374
foreach ($builder->wheres as $key => $value) {
375+
if ($key == '__soft_deleted') {
376+
if ($this->usesSoftDeletes($builder->model)) {
377+
if ($value == 1) {
378+
$query->whereNotNull($builder->model->getDeletedAtColumn());
379+
} else {
380+
$query->whereNull($builder->model->getDeletedAtColumn());
381+
}
382+
}
383+
continue;
384+
}
375385
$query->where($key, $value);
376386
}
377387

@@ -385,14 +395,6 @@ protected function performSearch(Builder $builder, ?int $perPage = 0, int $page
385395
$query->whereNotIn($key, $value);
386396
}
387397

388-
// If parsed documents are being stored in the model's table
389-
if (! $this->isExternalIndex($builder->model)) {
390-
// and the model uses soft deletes we need to exclude trashed rows
391-
if ($this->usesSoftDeletes($builder->model)) {
392-
$query->whereNull($builder->model->getDeletedAtColumn());
393-
}
394-
}
395-
396398
// Apply order by clauses that were set on the builder instance if any
397399
foreach ($builder->orders as $order) {
398400
$query->orderBy($order['column'], $order['direction']);

0 commit comments

Comments
 (0)