Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
gilour
/
back
/
app
/
Imports
:
AccountImport.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace App\Imports; use App\Models\Account; use App\Models\Organization; use Carbon\Carbon; use Maatwebsite\Excel\Concerns\ToModel; use Maatwebsite\Excel\Concerns\WithStartRow; class AccountImport implements ToModel, WithStartRow { public function startRow(): int { return 2; } public function model(array $row) { if (isset($row[8])) { $organization = Organization::query()->firstOrCreate(['model_id' => 3, 'full_name' => $row[8]]); } if (isset($row[11]) == 'Да') { $archive = true; } return new Account([ 'model_id' => 3, 'name' => $row[0], 'number' => $row[1], 'balance_of_the_date' => $row[2], 'organization_id' => $organization->id ?? null, 'archived' => $archive ?? false, 'added' => Carbon::parse($row[3])->format('Y-m-d'), 'deposit' => 0 ]); } }