forked from orchestral/database
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSearchServiceProvider.php
More file actions
28 lines (24 loc) · 833 Bytes
/
SearchServiceProvider.php
File metadata and controls
28 lines (24 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
namespace Orchestra\Database;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Query\Builder as QueryBuilder;
use Illuminate\Support\Arr;
use Illuminate\Support\ServiceProvider;
use Laravie\QueryFilter\Searchable;
class SearchServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
QueryBuilder::macro('whereLike', static function ($attributes, string $searchTerm) {
return (new Searchable($searchTerm, Arr::wrap($attributes)))->apply($this);
});
EloquentBuilder::macro('whereLike', static function ($attributes, string $searchTerm) {
return (new Searchable($searchTerm, Arr::wrap($attributes)))->apply($this);
});
}
}