|
@@ -0,0 +1,30 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Exports;
|
|
|
+
|
|
|
+
|
|
|
+use Maatwebsite\Excel\Concerns\FromCollection;
|
|
|
+use Maatwebsite\Excel\Concerns\WithTitle;
|
|
|
+use Illuminate\Support\Collection;
|
|
|
+
|
|
|
+class SingleSheetExport implements FromCollection,WithTitle
|
|
|
+{
|
|
|
+ protected $data;
|
|
|
+ protected $sheetName;
|
|
|
+
|
|
|
+ public function __construct(array $data, string $sheetName)
|
|
|
+ {
|
|
|
+ $this->data = $data;
|
|
|
+ $this->sheetName = $sheetName;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function collection()
|
|
|
+ {
|
|
|
+ return new Collection($this->data);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function title(): string
|
|
|
+ {
|
|
|
+ return $this->sheetName;
|
|
|
+ }
|
|
|
+}
|