WuYongJie 9595267ee7
Some checks failed
Tests / PHP 8.1 (push) Has been cancelled
Tests / PHP 8.2 (push) Has been cancelled
Tests / PHP 8.3 (push) Has been cancelled
chore: 导入 Akaunting 初始源码与团队协作规则
2026-07-20 18:20:25 +08:00

54 lines
1009 B
PHP

<?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
{
public $request_class = Request::class;
public $model = Model::class;
public $columns = [
'name',
'type',
];
public function model(array $row)
{
if (empty($row)) {
return;
}
if (self::hasRow($row)) {
return;
}
return new Model($row);
}
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;
}
}