akaunting/app/Imports/Sales/Customers.php

35 lines
728 B
PHP
Raw Normal View History

2019-11-16 07:21:14 +00:00
<?php
2019-12-31 12:49:09 +00:00
namespace App\Imports\Sales;
2019-11-16 07:21:14 +00:00
2020-01-19 22:26:35 +00:00
use App\Abstracts\Import;
2019-11-16 07:21:14 +00:00
use App\Http\Requests\Common\Contact as Request;
use App\Models\Common\Contact as Model;
2019-11-16 07:21:14 +00:00
2020-01-19 22:26:35 +00:00
class Customers extends Import
2019-11-16 07:21:14 +00:00
{
public function model(array $row)
{
return new Model($row);
2019-11-16 07:21:14 +00:00
}
public function map($row): array
{
2020-01-20 08:12:14 +00:00
$row = parent::map($row);
2019-11-16 07:21:14 +00:00
2021-11-07 23:40:40 +00:00
$country = array_search($row['country'], trans('countries'));
2020-01-20 08:12:14 +00:00
$row['type'] = 'customer';
2021-11-07 23:40:40 +00:00
$row['country'] = !empty($country) ? $country : null;
$row['currency_code'] = $this->getCurrencyCode($row);
$row['user_id'] = null;
2019-11-16 07:21:14 +00:00
return $row;
}
public function rules(): array
{
return (new Request())->rules();
}
2020-01-19 22:26:35 +00:00
}