user = $user; $this->type = $type; $this->settings = $settings; } /** * Execute the job. * * @param ContactMailer $mailer */ public function handle(ImportService $importService, UserMailer $userMailer) { $includeSettings = false; if (App::runningInConsole()) { Auth::onceUsingId($this->user->id); $this->user->account->loadLocalizationSettings(); } if ($this->type === IMPORT_JSON) { $includeData = $this->settings['include_data']; $includeSettings = $this->settings['include_settings']; $files = $this->settings['files']; $results = $importService->importJSON($files[IMPORT_JSON], $includeData, $includeSettings); } elseif ($this->type === IMPORT_CSV) { $map = $this->settings['map']; $headers = $this->settings['headers']; $timestamp = $this->settings['timestamp']; $results = $importService->importCSV($map, $headers, $timestamp); } else { $source = $this->settings['source']; $files = $this->settings['files']; $results = $importService->importFiles($source, $files); } $subject = trans('texts.import_complete'); $message = $importService->presentResults($results, $includeSettings); $userMailer->sendMessage($this->user, $subject, $message); if (App::runningInConsole()) { Auth::logout(); } } }