$bills 导出账单(with store) */ public function __construct(private readonly Collection $bills) { } /** * @return array */ public function sheets(): array { $usedNames = []; $sheets = []; foreach ($this->bills->groupBy('store_id') as $storeBills) { $store = $storeBills->first()->store; $storeId = (int) $storeBills->first()->store_id; $sheetTitle = SheetName::make($store->name ?? ('门店#' . $storeId), $storeId, $usedNames); $sheets[] = new BillExport($storeBills->values(), 0, $sheetTitle); } return $sheets; } }