2019-11-16 10:21:14 +03:00
|
|
|
<?php
|
|
|
|
|
2019-12-31 15:49:09 +03:00
|
|
|
namespace App\Imports\Sales\Sheets;
|
2019-11-16 10:21:14 +03:00
|
|
|
|
2020-01-20 01:26:35 +03:00
|
|
|
use App\Abstracts\Import;
|
2019-12-31 15:49:09 +03:00
|
|
|
use App\Http\Requests\Sale\Invoice as Request;
|
2020-01-20 22:58:49 +03:00
|
|
|
use App\Models\Sale\Invoice as Model;
|
2019-11-16 10:21:14 +03:00
|
|
|
|
2020-01-20 01:26:35 +03:00
|
|
|
class Invoices extends Import
|
2019-11-16 10:21:14 +03:00
|
|
|
{
|
|
|
|
public function model(array $row)
|
|
|
|
{
|
|
|
|
return new Model($row);
|
|
|
|
}
|
|
|
|
|
2020-01-20 22:58:49 +03:00
|
|
|
public function map($row): array
|
|
|
|
{
|
2020-02-25 14:56:48 +03:00
|
|
|
if ($this->isEmpty($row, 'invoice_number')) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
2020-01-20 22:58:49 +03:00
|
|
|
$row = parent::map($row);
|
|
|
|
|
2020-01-21 09:10:12 +03:00
|
|
|
$row['category_id'] = $this->getCategoryId($row, 'income');
|
|
|
|
$row['contact_id'] = $this->getContactId($row, 'customer');
|
2020-01-20 22:58:49 +03:00
|
|
|
|
|
|
|
return $row;
|
|
|
|
}
|
|
|
|
|
2019-11-16 10:21:14 +03:00
|
|
|
public function rules(): array
|
|
|
|
{
|
|
|
|
return (new Request())->rules();
|
|
|
|
}
|
2020-01-20 01:26:35 +03:00
|
|
|
}
|