diff --git a/app/Http/Controllers/Migration/StepsController.php b/app/Http/Controllers/Migration/StepsController.php index cdbe544f81..9bb9ee14ad 100644 --- a/app/Http/Controllers/Migration/StepsController.php +++ b/app/Http/Controllers/Migration/StepsController.php @@ -175,7 +175,11 @@ class StepsController extends BaseController ->endpoint(session('MIGRATION_ENDPOINT')) ->start(); - return view('migration.completed'); + if ($completeService->isSuccessful()) { + return view('migration.completed'); + } + + return view('migration.completed', ['customMessage' => $completeService->getErrors()[0]]); } public function completed() @@ -250,7 +254,7 @@ class StepsController extends BaseController 'documents' => $this->getDocuments(), ]; - $localMigrationData['force'] = array_key_exists('force', $company) ? true : false; + $localMigrationData['force'] = array_key_exists('force', $company); $file = storage_path("migrations/{$fileName}.zip"); diff --git a/app/Services/Migration/CompleteService.php b/app/Services/Migration/CompleteService.php index df774cdfed..140431388a 100644 --- a/app/Services/Migration/CompleteService.php +++ b/app/Services/Migration/CompleteService.php @@ -55,20 +55,16 @@ class CompleteService $body = \Unirest\Request\Body::multipart(['companies' => json_encode($data)], $files); - try { - $response = Request::post($this->getUrl(), $this->getHeaders(), $body); - } catch (\Exception $e) { - info($e->getMessage()); - } + $response = Request::post($this->getUrl(), $this->getHeaders(), $body); - if ($response->code == 200) { + if (in_array($response->code, [200])) { $this->isSuccessful = true; - } + } else { + info($response->raw_body); - if (in_array($response->code, [401, 422, 500])) { $this->isSuccessful = false; $this->errors = [ - 'Oops, something went wrong. Migration can\'t be processed at the moment.', + 'Oops, something went wrong. Migration can\'t be processed at the moment. Please checks the logs.', ]; } diff --git a/resources/views/migration/completed.blade.php b/resources/views/migration/completed.blade.php index 2a0da3471b..88d1d8005d 100644 --- a/resources/views/migration/completed.blade.php +++ b/resources/views/migration/completed.blade.php @@ -9,8 +9,7 @@

{!! trans('texts.welcome_to_the_new_version') !!}

- Migration has started. We'll update you with status, on your company e-mail. - + {{ $customMessage ?? 'Migration has started. We\'ll update you with status, on your company e-mail.' }}