我有一个功能,我可以在其中获取日期之间的所有销售记录。这是功能:
private function getSoldsBetweenDates($days, $user, $filter_by)
{
$date_from = Carbon::now()->subDays($days);
$date_to = Carbon::now();
return Inventory::where('inventory.client_id', $user->client_id)
->withCount(["sellRecord as $filter_by" => function($query) {
$query->select(DB::raw("created_at"))->take(1);
}])
->join('inventory_sell_records', 'inventory_sell_records.product_id', '=', 'inventory.id')
->groupBy('inventory_sell_records.product_id')
->whereBetween('inventory_sell_records.created_at', [$date_from, $date_to])
->paginate(100);
}
但现在我需要创建一个函数,该函数将从数据库中获取在日期范围内没有任何销售的所有记录。
就像是:
private function getDidntSellBetweenDates($days, $user, $filter_by)
{
What should I do here?
}
如何获得在日期范围内未售出的所有产品?