diff --git a/extend/catcher/CatchModelCollection.php b/extend/catcher/CatchModelCollection.php index 05751de..90d1e1d 100644 --- a/extend/catcher/CatchModelCollection.php +++ b/extend/catcher/CatchModelCollection.php @@ -1,12 +1,70 @@ items, $pid, $pidField, $children); } + + + /** + * 导出数据 + * + * @time 2020年10月21日 + * @param $header + * @param string $path + * @param string $disk + * @throws \PhpOffice\PhpSpreadsheet\Exception + * @return mixed|string[] + */ + public function export($header, $path = '', $disk = 'local') + { + $excel = new Class($header, $this->items) implements ExcelContract + { + protected $headers; + + protected $sheets; + + public function __construct($headers, $sheets) + { + $this->headers = $headers; + + $this->sheets = $sheets; + } + + public function headers(): array + { + // TODO: Implement headers() method. + return $this->headers; + } + + public function sheets() + { + // TODO: Implement sheets() method. + return $this->sheets; + } + }; + + if (!$path) { + $path = Utils::publicPath('exports'); + } + + return (new Excel)->save($excel, $path, $disk); + } } \ No newline at end of file