1+ <?php declare (strict_types=1 );
2+
3+ namespace ProtoneMedia \LaravelCrossEloquentSearch \Contracts ;
4+
5+ use Illuminate \Database \Eloquent \Builder ;
6+ use Illuminate \Support \Collection ;
7+
8+ interface SearcherContract
9+ {
10+ /**
11+ * Add a model to search through.
12+ *
13+ * @param Builder|class-string $query
14+ * @param string|array|Collection|null $columns
15+ * @param string|null $orderByColumn
16+ */
17+ public function add ($ query , $ columns = null , string $ orderByColumn = null ): self ;
18+
19+ /**
20+ * Add a full-text searchable model.
21+ *
22+ * @param Builder|class-string $query
23+ * @param string|array|Collection|null $columns
24+ * @param array $options
25+ * @param string|null $orderByColumn
26+ */
27+ public function addFullText ($ query , $ columns = null , array $ options = [], string $ orderByColumn = null ): self ;
28+
29+ /**
30+ * Add multiple models at once.
31+ *
32+ * @param array $queries
33+ */
34+ public function addMany (array $ queries ): self ;
35+
36+ /**
37+ * Set the order by column for the most recently added model.
38+ *
39+ * @param string $orderByColumn
40+ */
41+ public function orderBy (string $ orderByColumn ): self ;
42+
43+ /**
44+ * Order results in ascending order.
45+ */
46+ public function orderByAsc (): self ;
47+
48+ /**
49+ * Order results in descending order.
50+ */
51+ public function orderByDesc (): self ;
52+
53+ /**
54+ * Order results by relevance.
55+ */
56+ public function orderByRelevance (): self ;
57+
58+ /**
59+ * Order results by model type.
60+ *
61+ * @param array|string $modelClasses
62+ */
63+ public function orderByModel ($ modelClasses ): self ;
64+
65+ /**
66+ * Configure wildcard behavior.
67+ */
68+ public function beginWithWildcard (bool $ state = true ): self ;
69+
70+ /**
71+ * Configure wildcard behavior.
72+ */
73+ public function endWithWildcard (bool $ state = true ): self ;
74+
75+ /**
76+ * Enable case-insensitive searching.
77+ */
78+ public function ignoreCase (bool $ state = true ): self ;
79+
80+ /**
81+ * Enable sounds like searching.
82+ */
83+ public function soundsLike (bool $ state = true ): self ;
84+
85+ /**
86+ * Configure term parsing.
87+ */
88+ public function parseTerm (bool $ state = true ): self ;
89+
90+ /**
91+ * Configure pagination.
92+ */
93+ public function paginate (int $ perPage = 15 , string $ pageName = 'page ' , int $ page = null ): self ;
94+
95+ /**
96+ * Configure simple pagination.
97+ */
98+ public function simplePaginate (int $ perPage = 15 , string $ pageName = 'page ' , int $ page = null ): self ;
99+
100+ /**
101+ * Include model type in results.
102+ */
103+ public function includeModelType (string $ key = 'type ' ): self ;
104+
105+ /**
106+ * Perform the search.
107+ *
108+ * @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Contracts\Pagination\LengthAwarePaginator
109+ */
110+ public function search (string $ terms = null );
111+
112+ /**
113+ * Count the search results.
114+ */
115+ public function count (string $ terms = null ): int ;
116+
117+ /**
118+ * Parse search terms.
119+ */
120+ public static function parseTerms (string $ terms , callable $ callback = null ): Collection ;
121+ }
0 commit comments