-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
InvoiceItems.php
44 lines (36 loc) · 998 Bytes
/
InvoiceItems.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace App\Exports\Sales\Sheets;
use App\Abstracts\Export;
use App\Models\Document\DocumentItem as Model;
class InvoiceItems extends Export
{
public function collection()
{
return Model::with('document', 'item')->invoice()->collectForExport($this->ids, null, 'document_id');
}
public function map($model): array
{
$document = $model->document;
if (empty($document)) {
return [];
}
$model->invoice_number = $document->document_number;
$model->item_name = $model->item->name;
$model->item_description = $model->item->description;
$model->item_type = $model->item->type;
return parent::map($model);
}
public function fields(): array
{
return [
'invoice_number',
'item_name',
'item_description',
'item_type',
'quantity',
'price',
'total',
'tax',
];
}
}