Merge pull request #1068 from openclassify/muammertop

advs import fixed
This commit is contained in:
spektra2147 2021-05-04 15:51:11 +03:00 committed by GitHub
commit 4777ed6562
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,16 +4,21 @@ namespace Visiosoft\AdvsModule\Adv;
use Illuminate\Support\Str;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
class AdvsImport implements ToModel
class AdvsImport implements ToModel, WithHeadingRow
{
public function model(array $row)
{
return new AdvModel([
'name' => $row[0],
'slug' => Str::slug($row[0]),
'price' => $row[1],
'currency' => $row[2],
]);
if ($row['name'] !== null && $row['price'] !== null && $row['currency'] !== null) {
return new AdvModel([
'name' => $row['name'],
'slug' => Str::slug($row['name']),
'advs_desc' => $row['description'],
'price' => $row['price'],
'currency' => $row['currency'],
]);
}
}
}