/
home
/
sjslayjy
/
public_html
/
cropnet
/
app
/
Imports
/
Upload File
HOME
<?php namespace App\Imports; use Illuminate\Support\Collection; use Maatwebsite\Excel\Concerns\ToCollection; use Maatwebsite\Excel\Concerns\WithHeadingRow; use DB; class ImportMcc implements ToCollection, WithHeadingRow { /** * @param Collection $collection * * */ public function collection(Collection $collection){ if(count($collection) >0){ foreach($collection as $sheet){ $mcc =\DB::table('mcc')->where([['code','=',$sheet['mcc_code']],['name','=',$sheet['mcc_name']]])->first(); if(is_null($mcc)){ \DB::table('mcc')->insert([ 'code' => $sheet['mcc_code'], 'name' => $sheet['mcc_name'], ]); } } return true; }else{ return false; } } }