在 Laravel 中是否可以“追加”查询?
例如,在以下示例代码中是否可以这样做:
function crunchNumbersForToday()
{
return $this->crunchSomeInformationInRange(Payments::where('created_at', Carbon::now()));
}
function crunchNumbersInRange($range)
{
$paymentsToCrunch = Payment::where('state', 'payed')->append($range)->get();
// Work with the payments
}
在这种情况下,
created_at
字段的where
将被附加到查询中,其中state
等于payed
。这将使得查询变为:where created_at = '2015-07-08 12:00' AND state = payed
。