File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 48
48
return $ this ;
49
49
});
50
50
}
51
+
52
+ if (! Builder::hasMacro ('with ' )) {
53
+ /**
54
+ * Override the algolia search options to give you full control over the request,
55
+ * similar to official algolia-laravel package.
56
+ *
57
+ * Adds the final missing piece to scout to make the library useful.
58
+ *
59
+ * @param array $opts Latitude of the center
60
+ *
61
+ * @return Laravel\Scout\Builder
62
+ */
63
+ Builder::macro ('with ' , function ($ opts ) {
64
+ $ callback = $ this ->callback ;
65
+
66
+ $ this ->callback = function ($ algolia , $ query , $ options ) use ($ opts , $ callback ) {
67
+ $ options = array_merge ($ options , $ opts );
68
+
69
+ if ($ callback ) {
70
+ return call_user_func (
71
+ $ callback ,
72
+ $ algolia ,
73
+ $ query ,
74
+ $ options
75
+ );
76
+ }
77
+
78
+ return $ algolia ->search ($ query , $ options );
79
+ };
80
+
81
+ return $ this ;
82
+ });
83
+ }
You can’t perform that action at this time.
0 commit comments