fixed import category has row

This commit is contained in:
Cihan Şentürk 2024-02-21 11:01:38 +03:00 committed by GitHub
parent 0702847c79
commit acd3f3bc7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 20 additions and 0 deletions

View File

@ -10,6 +10,8 @@ class Categories extends Import
{
public $request_class = Request::class;
public $model = Model::class;
public $columns = [
'name',
'type',
@ -33,4 +35,22 @@ class Categories extends Import
return $row;
}
//This function is used in import classes. If the data in the row exists in the database, it is returned.
public function hasRow($row)
{
$has_row = $this->model::getWithoutChildren($this->columns)->each(function ($data) {
$data->setAppends([]);
$data->unsetRelations();
});
$search_value = [];
//In the model, the fields to be searched for the row are determined.
foreach ($this->columns as $key) {
$search_value[$key] = isset($row[$key]) ? $row[$key] : null;
}
return in_array($search_value, $has_row->toArray());
}
}