From c2e177e13b313a4ea83a579972a0e0676ca049d7 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 1 Feb 2023 08:43:32 +1100 Subject: [PATCH] Change error page for subscriptions where upgrade is not available --- app/Exceptions/Handler.php | 2 +- .../SubscriptionPlanSwitchController.php | 5 +++++ .../Subscriptions/ShowPlanSwitchRequest.php | 20 ++++++++++++++++--- app/Jobs/Util/WebhookSingle.php | 2 +- resources/views/errors/guest.blade.php | 4 ++-- .../views/errors/illustrated-layout.blade.php | 7 +++---- 6 files changed, 29 insertions(+), 11 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 1d6676407a..f2d53abf67 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -222,7 +222,7 @@ class Handler extends ExceptionHandler return response()->json(['message'=>'Too many requests'], 429); // } elseif ($exception instanceof FatalThrowableError && $request->expectsJson()) { // return response()->json(['message'=>'Fatal error'], 500); //@deprecated - } elseif ($exception instanceof AuthorizationException) { + } elseif ($exception instanceof AuthorizationException && $request->expectsJson()) { return response()->json(['message'=> $exception->getMessage()], 401); } elseif ($exception instanceof TokenMismatchException) { return redirect() diff --git a/app/Http/Controllers/ClientPortal/SubscriptionPlanSwitchController.php b/app/Http/Controllers/ClientPortal/SubscriptionPlanSwitchController.php index 3390512616..6fd26bbba7 100644 --- a/app/Http/Controllers/ClientPortal/SubscriptionPlanSwitchController.php +++ b/app/Http/Controllers/ClientPortal/SubscriptionPlanSwitchController.php @@ -55,4 +55,9 @@ class SubscriptionPlanSwitchController extends Controller ]); } + + public function not_availabe() + { + abort(404, 'ewwo'); + } } diff --git a/app/Http/Requests/ClientPortal/Subscriptions/ShowPlanSwitchRequest.php b/app/Http/Requests/ClientPortal/Subscriptions/ShowPlanSwitchRequest.php index a3fe7e8fb2..1a906018d8 100644 --- a/app/Http/Requests/ClientPortal/Subscriptions/ShowPlanSwitchRequest.php +++ b/app/Http/Requests/ClientPortal/Subscriptions/ShowPlanSwitchRequest.php @@ -1,14 +1,21 @@ entity->client; } - return false; + return null; } public function failed($exception = null) diff --git a/resources/views/errors/guest.blade.php b/resources/views/errors/guest.blade.php index 9df84c302c..0b2500ba83 100644 --- a/resources/views/errors/guest.blade.php +++ b/resources/views/errors/guest.blade.php @@ -1,5 +1,5 @@ @extends('portal.ninja2020.layout.error') -@section('title', __('Server Error')) -@section('code', '500') +@section('title', __($title) ?: 'Server Error') +@section('code', __($code) ?: '500') @section('message', __($message) ?: 'System Error') diff --git a/resources/views/errors/illustrated-layout.blade.php b/resources/views/errors/illustrated-layout.blade.php index 3f81c6cae1..0c6eb3f087 100644 --- a/resources/views/errors/illustrated-layout.blade.php +++ b/resources/views/errors/illustrated-layout.blade.php @@ -481,11 +481,10 @@ @yield('message')

- - + + {{ ctrans('texts.back_to', ['url' => parse_url(request()->getHttpHost())['host'] ?? request()->getHttpHost()]) }} +