Laravel Scout make updated rows unsearchable

Viewed 22

Since I have a lot of rows I need to update 1000 each time, but I also need to remove the updated rows from my scout index which I have tried using unsearchable() since the Laravel update() method doesn't seem to trigger a scout event to remove them.

I have tried to chain it like this but it does not work:

Items::where('state', 2)->where('active', 1)->limit(1000)->update(['active' => 0])->unsearchable();

In my model I have the setting:

public function shouldBeSearchable()
    {
        return $this->active == 1;
    }

But that only seem to trigger when I create a new row and save it and not when I update multiple ones.

So how can I update multiple rows and also remove them from my Scout index?

0 Answers
Related