advs import fixed

This commit is contained in:
muammertop 2021-05-04 15:24:35 +03:00
parent 016a0496e8
commit 188d42ca0d

View File

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