You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
834 B
39 lines
834 B
<?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) {
|
|
//
|
|
}
|
|
}
|