Akaunting/app/Exports/Common/Sheets/ItemTaxes.php

41 lines
848 B
PHP
Raw Normal View History

<?php
namespace App\Exports\Common\Sheets;
use App\Abstracts\Export;
2024-04-24 15:12:05 +00:00
use App\Http\Requests\Common\ItemTax as Request;
2024-05-22 16:26:16 +00:00
use App\Interfaces\Export\WithParentSheet;
use App\Models\Common\ItemTax as Model;
2024-05-22 16:26:16 +00:00
class ItemTaxes extends Export implements WithParentSheet
{
2024-04-24 15:12:05 +00:00
public $request_class = Request::class;
public function collection()
{
2021-06-27 08:40:46 +00:00
return Model::with('item', 'tax')->collectForExport($this->ids, null, 'item_id');
}
public function map($model): array
{
$item = $model->item;
if (empty($item)) {
return [];
}
$model->item_name = $model->item->name;
$model->tax_rate = $model->tax->rate;
return parent::map($model);
}
public function fields(): array
{
return [
'item_name',
'tax_rate',
];
}
}