-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Lines 13 to 17 in 3e606d5
| 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();
Metadata
Metadata
Assignees
Labels
No labels