File manager - Edit - /var/www/payraty/inventory_main/app/Exports/SalesReportExport.php
Back
<?php namespace App\Exports; use Maatwebsite\Excel\Concerns\FromArray; use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\ShouldAutoSize; /** * SalesReportExport */ class SalesReportExport implements FromArray, WithHeadings, ShouldAutoSize { protected $items; /** * __construct * * @param mixed $items * @return void */ public function __construct($items) { $this->items = $items; } /** * array * * @return array */ public function array(): array { $data = []; $sl = 1; foreach ($this->items as $item) { $r = []; $r[] = $sl; $r[] = make8digits($item->id); $r[] = custom_date($item->date); $r[] = $this->customerName($item); $r[] = $item->tax_amount; $r[] = $item->discount_amount; $r[] = $item->total; $r[] = $item->total - $item->total_paid; $data[] = $r; $sl++; } return $data; } /** * customerName * * @param mixed $item * @return void */ public function customerName($item) { if ($item->customer_id) { return ucfirst($item->customer['full_name'] ?? ''); } else { return ucfirst($item->customer['full_name'] ?? 'Walk-In Customer'); } } /** * headings * * @return array */ public function headings(): array { return [ '#', __('custom.invoice_id'), __('custom.date'), __('custom.customer'), __('custom.tax'), __('custom.discount'), __('custom.total'), __('custom.due') ]; } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.30 | Generation time: 0.28 |
proxy
|
phpinfo
|
Settings