status == 1) { $this->driver = new $job->type(); if(strpos($job->file, 'http') !== false) { $res = $this->driver->readFileByUrl($job->file); }else{ $file = new File(public_path('storage/'.$job->file)); $res = $this->driver->readFile($file); } if ($res) { $job->update([ 'status'=>2, 'success' => $res['success']??0, 'fails'=> $res['fails']??0, ]); } if (isset($res['errors']) && count($res['errors']) > 0) { $this->createErrorLogs($job, $res['errors']); } } } public function createErrorLogs(ImportJob $job, array $errors) { ImportJobLog::insert(array_map(function ($value) use ($job) { return array_merge($value, [ 'job_id'=>$job->id, 'created_at' => now(), 'updated_at' => now(), ]); }, $errors)); } }