items import/export

This commit is contained in:
denisdulici
2020-01-20 23:18:47 +03:00
parent 6923a3d6e4
commit b119deca9f
4 changed files with 43 additions and 8 deletions

View File

@ -9,7 +9,7 @@ class Items extends Export
{
public function collection()
{
$model = Model::usingSearchString(request('search'));
$model = Model::with(['category', 'tax'])->usingSearchString(request('search'));
if (!empty($this->ids)) {
$model->whereIn('id', (array) $this->ids);
@ -18,6 +18,14 @@ class Items extends Export
return $model->get();
}
public function map($model): array
{
$model->category_name = $model->category->name;
$model->tax_rate = $model->tax->rate;
return parent::map($model);
}
public function fields(): array
{
return [
@ -25,8 +33,8 @@ class Items extends Export
'description',
'sale_price',
'purchase_price',
'category_id',
'tax_id',
'category_name',
'tax_rate',
'enabled',
];
}