36 lines
756 B
PHP
Raw Normal View History

2019-11-16 10:21:14 +03:00
<?php
namespace App\Imports\Common;
2020-01-20 01:26:35 +03:00
use App\Abstracts\Import;
2019-11-16 10:21:14 +03:00
use App\Http\Requests\Common\Item as Request;
2020-01-20 23:18:47 +03:00
use App\Models\Common\Item as Model;
2019-11-16 10:21:14 +03:00
2020-01-20 01:26:35 +03:00
class Items extends Import
2019-11-16 10:21:14 +03:00
{
public function model(array $row)
{
return new Model($row);
2020-01-20 23:18:47 +03:00
}
public function map($row): array
{
$row = parent::map($row);
if (empty($row['category_id']) && !empty($row['category_name'])) {
2020-01-20 23:50:19 +03:00
$row['category_id'] = $this->getCategoryIdFromName($row, 'item');
2020-01-20 23:18:47 +03:00
}
if (empty($row['tax_id']) && !empty($row['tax_rate'])) {
2020-01-20 23:50:19 +03:00
$row['tax_id'] = $this->getTaxIdFromRate($row);
2020-01-20 23:18:47 +03:00
}
2019-11-16 10:21:14 +03:00
2020-01-20 23:18:47 +03:00
return $row;
2019-11-16 10:21:14 +03:00
}
public function rules(): array
{
return (new Request())->rules();
}
}