Closed dungnh closed 1 month ago
I can fix my code now. The updated code and Readme of 4.2.0 version may need to update correctly.
I just used to implement eloquentFilter\QueryFilter\Detection\Contract\ConditionsContract
instead of eloquentFilter\QueryFilter\Detection\Contract\DetectorConditionContract
@dungnh
Since I changed the name of the interface, that's right. I should have mentioned it in readme.
I have used custom detection conditions feature with old version and it worked well. But when I upgrade to 4.2.0 to work with Laravel 11, it got an error. I have setup and updated the classes for custom detection condition and I got the message:
detect() cannot be called statically
. The class implementing theeloquentFilter\QueryFilter\Detection\Contract\DetectorConditionContract
interface and it cannot declare the detect method as static.To Reproduce Steps to reproduce the behavior:
use eloquentFilter\QueryFilter\Detection\Contract\DetectorConditionContract;
use Illuminate\Support\Collection;
class FilterConditionsDetector implements DetectorConditionContract { protected $detector;
}
use eloquentFilter\QueryFilter\Queries\BaseClause; use Illuminate\Database\Eloquent\Builder;
class FilterRelatedQuery extends BaseClause { public function apply($query): Builder { if ($this->filter === 'custom_condition') { return ..... }
}
$user = new User(); $user->ignoreRequest(['page', 'sort', 'direction', 'keyword', 'column', 'operation'])->filter();