我正在尝试获取属于上个月的所有记录,到目前为止,我设法获取了上个月的所有记录,但到目前为止,我不确定如何只获取上个月的记录
$revenueMonth = Callback::where('created_at', '>=', Carbon::today()->startOfMonth()->subMonth())->sum('payment');
最佳答案
您的问题更清晰的解决方案:
$revenueMonth = Callback::whereMonth(
'created_at', '=', Carbon::now()->subMonth()->month
);
关于php - 检索上个月的所有行(Laravel + Eloquent),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46096260/