<?php

namespace App\Imports;

use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\ToCollection;
use Maatwebsite\Excel\Concerns\WithChunkReading;
use Maatwebsite\Excel\Concerns\WithBatchInserts;
use DB;



class PlaceImport implements ToCollection, WithChunkReading , WithBatchInserts
{
    /**
     * @param Collection $collection
     */
    public function collection(Collection $collection)
    {



        foreach($collection as $key => $value)
        {
            if($key > 0)
            {
                DB::table('places')->insert([


                    'Arabic_Name'	   =>$value[1]
                    ,'English_Name'  =>$value[2]
                    ,'Ship_Price'  =>$value[3]
                    ,'City'  =>$value[4]
                    ,'Delivery'  =>$value[5]
                    ,'created_at'  =>$value[6]
                    ,'updated_at'  =>$value[7]
                    ,'SearchCode'  =>$value[8]


                ]);
            }
        }

    }

    public function batchSize(): int
    {
        return 10000;
    }



    public function chunkSize(): int
    {
        return 10000;
    }
}
