问题描述
我可以使用以下内容来获取我所有信用的列表
I can use the following to obtain a list of all my credits
<?php
$marketplace = Balanced\Marketplace::mine();
$credits = $marketplace->credits->query()->all();
?>
我可以修改它以获得特定客户的信用
I can modify this to obtain the credits for a specific customer
$credits = $customer->credits->query()->all();
注意机会是从查询 $marketplace 到查询 $customer.
Note the chance is from querying $marketplace to querying $customer.
我可以修改 all() 或通过其他方式获得不同参数的积分吗?例如过去 24 小时或特定日期的积分,...
Can I modify all() or by other means obtain credits with different parameters.e.g. Credits in the last 24 hour or for a specific day,...
我知道我可以获得完整的积分列表,然后搜索它,但如果只需要一个子部分,似乎资源很匮乏.
I know I can get the entire list of credits and then search though it but it seems resource hungry to get everything if only a sub-section is required.
推荐答案
我相信你可以这样过滤
$customer->credits->query()->filter(
Credit::$f->created_at->lt($before),
Credit::$f->created_at->gte($after),
)->all();
这是互联网上的另一个示例,它也显示了如何通过元字段进行过滤 - https://gist.github.com/mjallday/5166040
Here's another example on the internet that shows how to filter via the meta field too - https://gist.github.com/mjallday/5166040
这篇关于获得特定日期的积分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!