diff --git a/app/Exports/SerialExport.php b/app/Exports/SerialExport.php new file mode 100644 index 0000000..153e5e9 --- /dev/null +++ b/app/Exports/SerialExport.php @@ -0,0 +1,68 @@ +itemCode = $itemCode; + $this->fromSerial = $fromSerial; + $this->toSerial = $toSerial; + } + + public function bindValue(Cell $cell, $value) + { + $cell->setValueExplicit((string) $value, DataType::TYPE_STRING); + + return true; + } + + public function collection() + { + $rows = []; + + for ($i = $this->fromSerial; $i <= $this->toSerial; $i++) { + $rows[] = [ + 'item_code' => $this->itemCode, + 'serial_number' => str_pad($i, 6, '0', STR_PAD_LEFT), + ]; + } + + return new Collection($rows); + } + + public function columnFormats(): array + { + return [ + 'B' => NumberFormat::FORMAT_TEXT, + ]; + } + + public function headings(): array + { + return [ + 'Item Code', + 'Serial Number', + ]; + } +}