2020-12-21 08:14:47 +00:00
|
|
|
<?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;
|
2020-12-21 08:14:47 +00:00
|
|
|
use App\Models\Common\ItemTax as Model;
|
|
|
|
|
|
2024-05-22 16:26:16 +00:00
|
|
|
class ItemTaxes extends Export implements WithParentSheet
|
2020-12-21 08:14:47 +00:00
|
|
|
{
|
2024-04-24 15:12:05 +00:00
|
|
|
public $request_class = Request::class;
|
|
|
|
|
|
2020-12-21 08:14:47 +00:00
|
|
|
public function collection()
|
|
|
|
|
{
|
2021-06-27 08:40:46 +00:00
|
|
|
return Model::with('item', 'tax')->collectForExport($this->ids, null, 'item_id');
|
2020-12-21 08:14:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|