@@ -18,9 +18,7 @@ class ScoutBuilder implements QueryBuilder
1818 * This method configures the underlying search builder by setting the query text,
1919 * and conditionally applying filters, sort orders, and additional instructions based
2020 * on the provided parameters. It also enforces a limit on the number of results,
21- * defaulting to 50 if no limit is specified. Any extra parameters, after excluding
22- * reserved keys (filters, instructions, sorts, text, and limit), are forwarded to the
23- * underlying search operation.
21+ * defaulting to 50 if no limit is specified.
2422 *
2523 * @param array $parameters An associative array of search criteria, which may include:
2624 * - 'text': An array containing 'value' (search string) and optionally 'trashed' ('with'|'only').
@@ -53,27 +51,36 @@ public function search(array $parameters = [])
5351 $ this ->applyInstructions ($ parameters ['instructions ' ]);
5452 });
5553
56- $ this ->queryBuilder
57- ->query (function (Builder $ query ) use ($ parameters ) {
58- app ()->make (QueryBuilder::class, ['query ' => $ query , 'resource ' => $ this ->resource ])
59- ->disableSecurity ()
60- ->search (
61- collect ($ parameters )
62- ->except ([
63- 'filters ' ,
64- 'instructions ' ,
65- 'sorts ' ,
66- 'text ' ,
67- 'limit ' ,
68- 'page ' ,
69- ])
70- ->all ()
71- );
72- });
73-
7454 return $ this ->queryBuilder ;
7555 }
7656
57+ /**
58+ * Forwards the extra parameters after excluding reserved keys (filters, instructions, sorts, text, and limit)
59+ * to the underlying search operation.
60+ *
61+ * @param \Laravel\Scout\Builder $query
62+ * @param array $parameters
63+ *
64+ * @return \Laravel\Scout\Builder The new query builder.
65+ */
66+ public function applyQueryCallback ($ query , $ parameters )
67+ {
68+ return app ()->make (QueryBuilder::class, ['query ' => $ query , 'resource ' => $ this ->resource ])
69+ ->disableSecurity ()
70+ ->search (
71+ collect ($ parameters )
72+ ->except ([
73+ 'filters ' ,
74+ 'instructions ' ,
75+ 'sorts ' ,
76+ 'text ' ,
77+ 'limit ' ,
78+ 'page ' ,
79+ ])
80+ ->all ()
81+ );
82+ }
83+
7784 /**
7885 * Apply multiple filters to the query builder.
7986 *
0 commit comments