Obtain credits for a specific day

2019-08-19 02:10发布

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条回答
贪生不怕死
2楼-- · 2019-08-19 02:45

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

查看更多
登录 后发表回答