61 lines
1.4 KiB
PHP
Raw Normal View History

2019-11-16 10:21:14 +03:00
<?php
namespace App\Exports\Sales\Sheets;
2019-11-16 10:21:14 +03:00
2020-01-20 02:05:40 +03:00
use App\Abstracts\Export;
2020-12-24 01:28:38 +03:00
use App\Models\Document\Document as Model;
2020-11-13 03:07:30 +03:00
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
2019-11-16 10:21:14 +03:00
class Invoices extends Export
2019-11-16 10:21:14 +03:00
{
public function collection()
{
$model = Model::invoice()->with('category')->usingSearchString(request('search'));
2019-11-16 10:21:14 +03:00
if (!empty($this->ids)) {
$model->whereIn('id', (array) $this->ids);
}
2020-03-02 23:13:36 +03:00
return $model->cursor();
2019-11-16 10:21:14 +03:00
}
2020-01-20 22:58:49 +03:00
public function map($model): array
{
$model->category_name = $model->category->name;
$model->invoice_number = $model->document_number;
$model->invoiced_at = $model->issued_at;
2020-12-24 01:28:38 +03:00
2020-01-20 22:58:49 +03:00
return parent::map($model);
}
2020-01-20 02:05:40 +03:00
public function fields(): array
2019-11-16 10:21:14 +03:00
{
return [
'invoice_number',
2019-11-16 10:21:14 +03:00
'order_number',
2020-01-11 16:57:32 +03:00
'status',
'invoiced_at',
2019-11-16 10:21:14 +03:00
'due_at',
'amount',
'currency_code',
'currency_rate',
2020-01-20 22:58:49 +03:00
'category_name',
2019-11-16 10:21:14 +03:00
'contact_name',
'contact_email',
'contact_tax_number',
'contact_phone',
2019-11-16 10:21:14 +03:00
'contact_address',
'notes',
'footer',
];
}
2020-11-13 03:07:30 +03:00
public function columnFormats(): array
{
return [
'D' => NumberFormat::FORMAT_DATE_YYYYMMDD,
'E' => NumberFormat::FORMAT_DATE_YYYYMMDD,
];
}
}