|
public function process($builder, $query = null) |
|
{ |
|
if (is_null($query)) { |
|
$query = Request::query(); |
|
} |
I suggest changing it to like this:
class Searchable {
protected $params = [];
protected $request;
public function __construct(Request $request = null)
{
$this->request = $request ?? Request::instance();
}
public function process($builder, $query = null)
{
if (is_null($query)) {
$query = $this->request->query();
}
...
You can probably use it as before,
$users = User::query()
...
->where(...)
->search(new UserSearch())
->get();
or you can pass an instance of the Request class.
$users = User::query()
...
->where(...)
->search(new UserSearch($request))
->get();
Seaaaaarch/src/Searchable.php
Lines 13 to 17 in 3e606d5
I suggest changing it to like this:
You can probably use it as before,
or you can pass an instance of the
Requestclass.