Server IP : 66.29.132.124 / Your IP : 52.15.209.178 Web Server : LiteSpeed System : Linux business141.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : wavevlvu ( 1524) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/wavevlvu/book24.ng/modules/Flight/Imports/ |
Upload File : |
<?php namespace Modules\Flight\Imports; use Illuminate\Contracts\Queue\ShouldQueue; use Maatwebsite\Excel\Concerns\Importable; use Maatwebsite\Excel\Concerns\ToModel; use Maatwebsite\Excel\Concerns\WithBatchInserts; use Maatwebsite\Excel\Concerns\WithChunkReading; use Maatwebsite\Excel\Concerns\WithHeadingRow; use Maatwebsite\Excel\Concerns\WithUpsertColumns; use Maatwebsite\Excel\Concerns\WithUpserts; use Modules\Flight\Models\Airport; class AirportImportIATA implements WithChunkReading,ToModel,ShouldQueue,WithHeadingRow,WithBatchInserts,WithUpserts,WithUpsertColumns { use Importable; public function model(array $row) { $data = [ 'name' => $row['name'], 'code' => $row['iata_code'], 'map_lat' => $row['latitude_deg'], 'map_lng' => $row['longitude_deg'], 'address' => $row['municipality'], 'country'=>$row['iso_country'], 'status'=>'draft' ]; $a = new Airport(); $a->fillByAttr(array_keys($data),$data); return $a; } /** * @return array */ public function upsertColumns() { return ['name', 'map_lat','map_lng','address','country']; } /** * @return string|array */ public function uniqueBy() { return 'code'; } public function batchSize(): int { return 50; } public function chunkSize(): int { return 500; } }