filepath = $filepath; } /** * Execute the job. */ public function handle(): void { $mapping = [ 'name' => 0, 'translation' => 1, ]; $fileStream = fopen($this->filepath, 'r'); $skipHeader = true; $finalarray = array(); while ($row = fgetcsv($fileStream)) { if ($skipHeader) { $skipHeader = false; continue; } $finalarray[] = array( 'name' => $row[$mapping['name']], 'translation' => $row[$mapping['translation']], ); //Word::updateOrCreate( // [ // 'name' => $row[$mapping['name']], // 'translation' => $row[$mapping['translation']], // ] //); } DB::table('words')->upsert($finalarray, 'name', 'translation'); //fclose($fileStream); //Storage::delete($this->filepath); } }