在 Spatie\QueryBuilder ,报错:Call to undefined method Spatie\\QueryBuilder\\AllowedFilter::endsWithStrict()
1、在 Spatie\QueryBuilder ,报错:Call to undefined method Spatie\\QueryBuilder\\AllowedFilter::endsWithStrict()。如图1
{ "status_code": 500, "code": 0, "message": "Call to undefined method Spatie\\QueryBuilder\\AllowedFilter::endsWithStrict()" }
2、在 vendor/spatie/laravel-query-builder/src/AllowedFilter.php 中搜索:endsWithStrict,确认 endsWithStrict 方法不存在。
3、查看 composer.json ,”spatie/laravel-query-builder”: “^5.2”, 。使用 Composer 自动更新到该包的最新兼容版本,5.2.0 => 5.7.0。如图2
PS E:\wwwroot\object> composer update spatie/laravel-query-builder Loading composer repositories with package information Updating dependencies Lock file operations: 0 installs, 1 update, 0 removals - Upgrading spatie/laravel-query-builder (5.2.0 => 5.7.0) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 0 installs, 1 update, 1 removal - Downloading spatie/laravel-query-builder (5.7.0) - Removing laravel/telescope (v5.2.2) - Upgrading spatie/laravel-query-builder (5.2.0 => 5.7.0): Extracting archive Generating optimized autoload files
4、在 Spatie\QueryBuilder ,不再报错。查看生成的 SQL,符合预期。如图3
select `table`.* from `table` where `table`.`shipping_type` = 2 and `shipping_at_gmt` >= '2024-06-14 02:00:51' and `shipping_at_gmt` <= '2024-09-14 02:00:51' and ( `table`.`plat_order_no` LIKE '%GM' or `table`.`plat_order_no` LIKE '%20' ) order by `operated_at_gmt` desc limit 100 offset 0
近期评论