/
home
/
henzagold
/
server
/
app
/
Te
/
File Upload :
llllll
Current File: /home/henzagold/server/app/Te/ExcelCollection.php
<?php namespace App\DB\Te; use Illuminate\Support\Arr; use Maatwebsite\Excel\Concerns\FromCollection; use Maatwebsite\Excel\Concerns\ShouldAutoSize; use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\WithEvents; use Maatwebsite\Excel\Events\BeforeExport; use Maatwebsite\Excel\Events\AfterSheet; class ExcelCollection implements FromCollection, WithHeadings, ShouldAutoSize, WithEvents { /** * TableEngineExport constructor. */ public function __construct($export, $cols) { $this->export = $export; $this->show = array_keys($cols); $this->head = array_values($cols); } public function collection() { return $this->export->map(function ($value, $key) { $exp = []; $all = $value->toArray(); foreach ($this->show as $val) { $exp[$val] = Arr::get($all, $val); } return collect($exp); }); } public function registerEvents(): array { return [ AfterSheet::class => function (AfterSheet $event) { $event->sheet->getDelegate()->setRightToLeft(true); }, ]; } /** * @inheritDoc */ public function headings(): array { return $this->head; } }
Copyright ©2k19 -
Hexid
|
Tex7ure