43 lines
845 B
PHP
Raw Normal View History

2022-06-01 10:15:55 +03:00
<?php
namespace App\Imports\Settings;
use App\Abstracts\Import;
use App\Http\Requests\Setting\Tax as Request;
use App\Models\Setting\Tax as Model;
class Taxes extends Import
{
2023-03-07 15:18:14 +03:00
public $request_class = Request::class;
2022-06-01 10:15:55 +03:00
public function model(array $row)
{
2023-08-14 14:04:04 +03:00
if (empty($row)) {
return;
}
2022-06-01 10:15:55 +03:00
return new Model($row);
}
2023-08-14 14:04:04 +03:00
public function map($row): array
{
$row = parent::map($row);
if ($row['type'] == 'compound') {
$compound_tax = Model::where('type', 'compound')->first();
if ($compound_tax) {
$this->request_class = null;
// TODO: Add exception error
// throw new \Exception('Compound tax already exists.');
return [];
}
}
return $row;
}
2022-06-01 10:15:55 +03:00
}