File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -123,13 +123,27 @@ public static function makeAllSearchable($chunk = null)
123123 $ softDelete = static ::usesSoftDelete () && config ('scout.soft_delete ' , false );
124124
125125 $ self ->newQuery ()
126+ ->when (true , function ($ query ) use ($ self ) {
127+ $ self ->makeAllSearchableUsing ($ query );
128+ })
126129 ->when ($ softDelete , function ($ query ) {
127130 $ query ->withTrashed ();
128131 })
129132 ->orderBy ($ self ->getKeyName ())
130133 ->searchable ($ chunk );
131134 }
132135
136+ /**
137+ * Modify the query used to retrieve models when making all of the models searchable.
138+ *
139+ * @param \Illuminate\Database\Eloquent\Builder $query
140+ * @return \Illuminate\Database\Eloquent\Builder
141+ */
142+ protected function makeAllSearchableUsing ($ query )
143+ {
144+ return $ query ;
145+ }
146+
133147 /**
134148 * Make the given model instance searchable.
135149 *
Original file line number Diff line number Diff line change @@ -66,6 +66,14 @@ public function newQuery()
6666 {
6767 $ mock = m::mock (Builder::class);
6868
69+ $ mock ->shouldReceive ('when ' )
70+ ->with (true , m::type ('Closure ' ))
71+ ->andReturnUsing (function ($ condition , $ callback ) use ($ mock ) {
72+ $ callback ($ mock );
73+
74+ return $ mock ;
75+ });
76+
6977 $ mock ->shouldReceive ('orderBy ' )
7078 ->with ('id ' )
7179 ->andReturnSelf ()
You can’t perform that action at this time.
0 commit comments