60 lines
1.3 KiB
PHP
Raw Normal View History

2019-11-16 10:21:14 +03:00
<?php
2019-12-31 15:49:09 +03:00
namespace App\Exports\Purchases\Sheets;
2019-11-16 10:21:14 +03:00
2020-01-20 02:05:40 +03:00
use App\Abstracts\Export;
2019-12-31 15:49:09 +03:00
use App\Models\Purchase\Bill as Model;
2020-11-13 03:07:30 +03:00
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
2019-11-16 10:21:14 +03:00
2020-11-13 03:07:30 +03:00
class Bills extends Export implements WithColumnFormatting
2019-11-16 10:21:14 +03:00
{
public function collection()
{
2020-06-07 12:11:37 +03:00
$model = Model::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-21 09:55:12 +03:00
public function map($model): array
{
$model->category_name = $model->category->name;
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 [
'bill_number',
'order_number',
2020-01-11 16:57:32 +03:00
'status',
2019-11-16 10:21:14 +03:00
'billed_at',
'due_at',
'amount',
'currency_code',
'currency_rate',
2020-01-21 09:55:12 +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,
];
}
}