Using Laravel scout I want to delete a record (on an Agent model), everything works well except that I'm redirecting to a list of agents after the delete, and since the queue is yet to be processed the deleted agent comes back from Meilisearch, but the Eloquent model doesn't exist anymore, resulting in an error Attempt to read property "id" on null
:
// getting agents to display in the view
Agent::search($this->search)
->orderBy('id', 'asc')
->paginate($this->perPage)
// showing an agent ID in a loop in the view
{{ $agent->user->id }}
If reloading the page the list is fine - the deleted user has successfully been deleted. How can I prevent this error?