Files
exchange-2.0/app/Classes/Modules/Imports/Services/ImportsDebtor.php
T
2022-03-02 09:54:12 +08:00

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 [
];
}
}