-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
I'm using dev-master version of laravel-scout-postgres.
Both withTrashed and onlyTrashed method are not properly handled.
Scout Builder has __soft_deleted in wheres attribute when its config soft_delete set to true. This will throw an Exception because no such column in the table.
Current PostgresEngine only set $query->whereNull($builder->model->getDeletedAtColumn()); if the model use SoftDeletes.
I modify the engine to deal with this problem.
// Handle soft deletes
if (!$this->isExternalIndex($builder->model)) {
if ($this->usesSoftDeletes($builder->model) && isset($builder->wheres['__soft_deleted'])) {
if ($builder->wheres['__soft_deleted']) {
$query->whereNotNull($builder->model->getDeletedAtColumn());
} else {
$query->whereNull($builder->model->getDeletedAtColumn());
}
unset($builder->wheres['__soft_deleted']);
}
}
// Apply where clauses that were set on the builder instance if any
foreach ($builder->wheres as $key => $value) {
$query->where($key, $value);
$bindings->push($value);
}
/* Deleted
// If parsed documents are being stored in the model's table
if (! $this->isExternalIndex($builder->model)) {
// and the model uses soft deletes we need to exclude trashed rows
if ($this->usesSoftDeletes($builder->model)) {
$query->whereNull($builder->model->getDeletedAtColumn());
}
}
*/Metadata
Metadata
Assignees
Labels
No labels