File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 44
55use Illuminate \Database \Eloquent \Builder as EloquentBuilder ;
66use Illuminate \Database \Eloquent \Model ;
7+ use Illuminate \Database \Eloquent \Relations \HasManyThrough ;
78use Illuminate \Database \Eloquent \Scope ;
89use Laravel \Scout \Events \ModelsFlushed ;
910use Laravel \Scout \Events \ModelsImported ;
@@ -45,5 +46,21 @@ public function extend(EloquentBuilder $builder)
4546 event (new ModelsFlushed ($ models ));
4647 });
4748 });
49+
50+ HasManyThrough::macro ('searchable ' , function ($ chunk = null ) {
51+ $ this ->chunkById ($ chunk ?: config ('scout.chunk.searchable ' , 500 ), function ($ models ) {
52+ $ models ->filter ->shouldBeSearchable ()->searchable ();
53+
54+ event (new ModelsImported ($ models ));
55+ });
56+ });
57+
58+ HasManyThrough::macro ('unsearchable ' , function ($ chunk = null ) {
59+ $ this ->chunkById ($ chunk ?: config ('scout.chunk.searchable ' , 500 ), function ($ models ) {
60+ $ models ->filter ->shouldBeSearchable ()->searchable ();
61+
62+ event (new ModelsImported ($ models ));
63+ });
64+ });
4865 }
4966}
You can’t perform that action at this time.
0 commit comments