items import/export
This commit is contained in:
@ -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',
|
||||
];
|
||||
}
|
||||
|
Reference in New Issue
Block a user