commit
567c7bc20b
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\BeforeExport;
|
||||
use Maatwebsite\Excel\Events\BeforeWriting;
|
||||
use Maatwebsite\Excel\Events\BeforeSheet;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
|
||||
class CommonExport implements FromCollection, WithEvents
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
// Handle by a closure.
|
||||
BeforeExport::class => [self::class, "beforeExport"]
|
||||
];
|
||||
}
|
||||
|
||||
public static function beforeExport(BeforeExport $event) {
|
||||
//
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue