mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
45 lines
834 B
PHP
45 lines
834 B
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Imports\Services;
|
|
|
|
use App\Models\Company;
|
|
|
|
use Maatwebsite\Excel\Concerns\ToModel;
|
|
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
use Maatwebsite\Excel\Concerns\WithBatchInserts;
|
|
use Maatwebsite\Excel\Concerns\WithValidation;
|
|
|
|
class ImportsDebtor implements ToModel, WithHeadingRow, WithBatchInserts, WithValidation
|
|
{
|
|
public function __construct() {
|
|
|
|
}
|
|
|
|
public function model($row = [])
|
|
{
|
|
$reference = str_replace('/CIEF', '', $row['2nd_description']);
|
|
|
|
$debtor = $row['code'];
|
|
$company = Company::where('reference', $reference)->first();
|
|
|
|
if ($company) {
|
|
$company->debtor = $debtor;
|
|
$company->update();
|
|
}
|
|
|
|
return [];
|
|
}
|
|
|
|
public function batchSize(): int
|
|
{
|
|
return 100;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
|
|
];
|
|
}
|
|
}
|