没有不值得去解决的问题,也没有不值得去学习的技术!

Error in Spatie\QueryBuilder: Call to undefined method Spatie\\QueryBuilder\\AllowedFilter::endsWithStrict()

在 Spatie\QueryBuilder ,报错:Call to undefined method Spatie\\QueryBuilder\\AllowedFilter::endsWithStrict()

1. In Spatie\QueryBuilder, an error occurred: Call to undefined method Spatie\\QueryBuilder\\AllowedFilter::endsWithStrict(). See Figure 1.

In Spatie\QueryBuilder, an error occurred: Call to undefined method Spatie\\QueryBuilder\\AllowedFilter::endsWithStrict()
Figure 1
JSON

{
    "status_code": 500,
    "code": 0,
    "message": "Call to undefined method Spatie\\QueryBuilder\\AllowedFilter::endsWithStrict()"
}

2. Searched for endsWithStrict in vendor/spatie/laravel-query-builder/src/AllowedFilter.php and confirmed that the endsWithStrict method does not exist.

3. Checked composer.json: “spatie/laravel-query-builder”: “^5.2”,. Used Composer to automatically update to the latest compatible version of the package, 5.2.0 => 5.7.0. See Figure 2.

Checked composer.json: "spatie/laravel-query-builder": "^5.2",. Used Composer to automatically update to the latest compatible version of the package, 5.2.0 => 5.7.0
Figure 2
Plaintext

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. In Spatie\QueryBuilder, the error no longer occurs. Checked the generated SQL, and it meets expectations. See Figure 3.

In Spatie\QueryBuilder, the error no longer occurs. Checked the generated SQL, and it meets expectations
Figure 3
SQL

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

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系