add import has row data check

This commit is contained in:
Cihan Şentürk
2023-08-16 18:18:17 +03:00
committed by GitHub
parent e6c029904b
commit b46e08a25d
2 changed files with 63 additions and 1 deletions

View File

@@ -11,10 +11,20 @@ class Transactions extends Import
{
use TraitsTransactions;
public $model = Model::class;
public $request_class = Request::class;
public $columns = [
'number',
];
public function model(array $row)
{
if (self::hasRow($row)) {
return;
}
return new Model($row);
}
@@ -29,8 +39,15 @@ class Transactions extends Import
$row['category_id'] = $this->getCategoryId($row, $real_type);
$row['contact_id'] = $this->getContactId($row, $real_type);
$row['document_id'] = $this->getDocumentId($row);
$row['parent_id'] = $this->getParentId($row);
$row['parent_id'] = $this->getParentId($row) ?? 0;
return $row;
}
public function prepareRules($rules): array
{
$rules['number'] = 'required|string';
return $rules;
}
}