private function tantargyak($file) { $tantcount = Subject::all()->count(); //insert tantargyak //tantargyak $tantargyak = Excel::selectSheetsByIndex(3)->load($file, function ($reader) { })->get(array('tantargy', 'rovidites'))->toArray(); try { foreach ($tantargyak as $tant) { if ($tant['tantargy'] != "") { $ment = Subject::firstOrCreate(array('subject_name' => $tant['tantargy'], 'subject_shortname' => $tant['rovidites'])); } } $tantcount = Subject::all()->count() - $tantcount; return $tantcount; } catch (\Exception $e) { $message = "Import file is not valid! Please check"; return view('import.error', compact('message')); } }