Obtain credits for a specific day

牧云@^-^@ 提交于 2020-01-16 10:00:22

问题


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();

Note the chance is from querying $marketplace to querying $customer.

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.


回答1:


I believe you can filter like this

$customer->credits->query()->filter(
    Credit::$f->created_at->lt($before),
    Credit::$f->created_at->gte($after),
)->all();

Here's another example on the internet that shows how to filter via the meta field too - https://gist.github.com/mjallday/5166040



来源:https://stackoverflow.com/questions/21256716/obtain-credits-for-a-specific-day

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!