From a99aa30669a5980cd6403abf98d7f2292833a0f5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 23 Jun 2021 11:57:40 +1000 Subject: [PATCH] Forward request to V5 --- .../Controllers/Migration/StepsController.php | 25 ++++++++++++ app/Http/Requests/MigrationForwardRequest.php | 30 +++++++++++++++ ...21_06_22_234707_add_forward_url_for_v5.php | 30 +++++++++++++++ resources/views/accounts/management.blade.php | 38 ++++++++++++++++++- routes/web.php | 1 + 5 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 app/Http/Requests/MigrationForwardRequest.php create mode 100644 database/migrations/2021_06_22_234707_add_forward_url_for_v5.php diff --git a/app/Http/Controllers/Migration/StepsController.php b/app/Http/Controllers/Migration/StepsController.php index 68b2001620..c659ff58f9 100644 --- a/app/Http/Controllers/Migration/StepsController.php +++ b/app/Http/Controllers/Migration/StepsController.php @@ -6,6 +6,7 @@ use App\Http\Controllers\BaseController; use App\Http\Requests\MigrationAuthRequest; use App\Http\Requests\MigrationCompaniesRequest; use App\Http\Requests\MigrationEndpointRequest; +use App\Http\Requests\MigrationForwardRequest; use App\Http\Requests\MigrationTypeRequest; use App\Libraries\Utils; use App\Models\Account; @@ -15,6 +16,8 @@ use App\Services\Migration\CompleteService; use App\Traits\GenerateMigrationResources; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Storage; +use Validator; +use Illuminate\Http\Request; class StepsController extends BaseController { @@ -83,6 +86,28 @@ class StepsController extends BaseController ); } + public function forwardUrl(Request $request) + { + + $rules = [ + 'url' => 'nullable|url', + ]; + + $validator = Validator::make($request->all(), $rules); + + if ($validator->fails()) { + return back() + ->withErrors($validator) + ->withInput(); + } + + $account = \Auth::user()->account; + $account->forward_url_for_v5 = rtrim($request->input('url'),'/'); + $account->save(); + + return back(); + } + public function endpoint() { if ($this->shouldGoBack('endpoint')) { diff --git a/app/Http/Requests/MigrationForwardRequest.php b/app/Http/Requests/MigrationForwardRequest.php new file mode 100644 index 0000000000..3cb594e913 --- /dev/null +++ b/app/Http/Requests/MigrationForwardRequest.php @@ -0,0 +1,30 @@ + 'nullable|url', + ]; + } +} diff --git a/database/migrations/2021_06_22_234707_add_forward_url_for_v5.php b/database/migrations/2021_06_22_234707_add_forward_url_for_v5.php new file mode 100644 index 0000000000..718c7e31d0 --- /dev/null +++ b/database/migrations/2021_06_22_234707_add_forward_url_for_v5.php @@ -0,0 +1,30 @@ +text('forward_url_for_v5')->default(''); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} diff --git a/resources/views/accounts/management.blade.php b/resources/views/accounts/management.blade.php index d9efb89796..a72f4ccf86 100644 --- a/resources/views/accounts/management.blade.php +++ b/resources/views/accounts/management.blade.php @@ -264,9 +264,45 @@ - {!! Former::close() !!} +
+
+

Forward customers to V5

+
+
+
+ {{ csrf_field() }} +
+ +
+
+ Once you are ready to forward your customers, enter your client portal URL for V5 here:
+

+
+
+
+ +
+ + @if($errors->has('url')) +
+ @foreach ($errors->get('url') as $message) + + + {{ $message }} + + @endforeach +
+ @endif +
+ +
+
+
+
+
+ @if (! Auth::user()->account->isNinjaOrLicenseAccount())
diff --git a/routes/web.php b/routes/web.php index ab2062bfb4..107c8e9d5b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -159,6 +159,7 @@ Route::group(['middleware' => ['lookup:user', 'auth:user']], function () { Route::get('migration/companies', 'Migration\StepsController@companies'); Route::post('migration/companies', 'Migration\StepsController@handleCompanies'); Route::get('migration/completed', 'Migration\StepsController@completed'); + Route::post('migration/forward', 'Migration\StepsController@forwardUrl'); Route::get('migration/import', 'Migration\StepsController@import');