我正在尝试获取属于上个月的所有记录,到目前为止我设法获取了上个月的所有记录,但到目前为止,我不确定如何仅获取上个月的记录
I'm trying to get all records that belongs to last month, so far I managed to get all from last month but to date today, I'm not sure how I can get only for last month
$revenueMonth = Callback::where('created_at', '>=', Carbon::today()->startOfMonth()->subMonth())->sum('payment');
更清晰的解决你的问题:
More clear solution for your problem:
$revenueMonth = Callback::whereMonth(
'created_at', '=', Carbon::now()->subMonth()->month
);
这篇关于检索上个月的所有行(Laravel + Eloquent)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!