Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving a Soft-Deleted Eloquent Model makes it searchable again #834

Closed
matrad opened this issue May 31, 2024 · 3 comments
Closed

Saving a Soft-Deleted Eloquent Model makes it searchable again #834

matrad opened this issue May 31, 2024 · 3 comments

Comments

@matrad
Copy link

matrad commented May 31, 2024

Scout Version

10.1.0

Scout Driver

Algolia

Laravel Version

11.x

PHP Version

8.1.4

Database Driver & Version

No response

SDK Version

No response

Meilisearch CLI Version

No response

Description

When we retrieve a soft-deleted model from the Database and Save this model, it becomes again searchable.

Steps To Reproduce

  • Create a new Model entry in the Database
  • (Soft) Delete the created model
  • Retrieve the Soft-Deleted Model with Model::withTrashed()->where('id', 111)->first()
  • Update a Property on the Model, like $model->comment = 'test';
  • Save the Model with $model->save()
  • The saved() Listener is fired and the Model becomes searchable, but it's still trashed
  • The model should not be searchable if the soft_delete config is set to false
Copy link

github-actions bot commented Jun 6, 2024

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

@Boorinio
Copy link
Contributor

Boorinio commented Jun 8, 2024

Hey @matrad
There is an example in the repo with the following
image

Do you have the trashed check in the shouldBeSearchable in your model? Cause from what I am seeing it should take care of it from the observer.

@driesvints
Copy link
Member

Thanks @Boorinio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants