/
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 ImportBankMasterData implements ToCollection, WithHeadingRow { /** * @param Collection $collection * * */ public function collection(Collection $collection){ if(count($collection) >0){ // dd($collection); foreach($collection as $sheet){ $master =\DB::table('bank_masters')->where([['bank_name','=',$sheet['bank_name']],['ifsc_code','=',$sheet['ifsc_code']],['branch','=',$sheet['branch']]])->first(); if(is_null($master)){ \DB::table('bank_masters')->insert(['bank_name' => $sheet['bank_name'],'ifsc_code' => $sheet['ifsc_code'],'branch' => $sheet['branch'],'created_by' => \Auth::user()->id ]); } } return true; }else{ return false; } } }