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

Support for Scout shouldBeSearchable #32

Closed

Conversation

BrandonJamesBorders
Copy link

Scout's shouldBeSearchable function fires a delete record on all save/create events. This makes sense as Scout does not keep track if models have been added before or not.

Change Summary

This update checks for the model's existence before attempting to delete it.

PR Checklist

Scout's `shouldBeSearchable` function fires a delete record on all save/create events. This makes sense as Scout does not keep track if models have been added before or not. 

This update checks for the model's existence before attempting to delete it.
@@ -123,9 +123,14 @@ public function deleteDocument(Collection $collectionIndex, $modelId): array
/**
* @var $document Document
*/
$document = $collectionIndex->getDocuments()[(string) $modelId];
$document = $collectionIndex->getDocuments()[(string) $modelId] ?? null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to how getDocuments works, this has been problematic in the past, so we'd need to remove the ?? null (#7)


return $document->delete();
// dd($document);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should maybe remove the debug code?

@arayiksmbatyan
Copy link
Contributor

Hi @BrandonJamesBorders,
This issue was fixed in this pr #59

@manavo
Copy link
Contributor

manavo commented Jun 16, 2023

@arayiksmbatyan can close this PR then?

@arayiksmbatyan
Copy link
Contributor

@manavo Yes.
I will close this PR.

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

Successfully merging this pull request may close these issues.

3 participants