diff --git a/app/Models/Account.php b/app/Models/Account.php index d91fd622fdb8..49a3cff5c254 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -1733,6 +1733,29 @@ class Account extends Eloquent { return $this->hasFeature(FEATURE_CLIENT_PORTAL_PASSWORD) && $this->enable_portal_password; } + + public function getBaseUrl() + { + if ($this->hasFeature(FEATURE_CUSTOM_URL)) { + if ($this->iframe_url) { + return $this->iframe_url; + } + + if (Utils::isNinjaProd() && ! Utils::isReseller()) { + $url = $this->present()->clientPortalLink(); + } else { + $url = url('/'); + } + + if ($this->subdomain) { + $url = Utils::replaceSubdomain($url, $this->subdomain); + } + + return $url; + } else { + return url('/'); + } + } } Account::creating(function ($account) diff --git a/resources/views/partials/email_templates.blade.php b/resources/views/partials/email_templates.blade.php index 10e5f1b4094a..488e4c172d57 100644 --- a/resources/views/partials/email_templates.blade.php +++ b/resources/views/partials/email_templates.blade.php @@ -33,14 +33,14 @@ 'number': invoice ? invoice.invoice_number : '0001', 'password': passwordHtml, 'documents': documentsHtml, - 'viewLink': '{{ link_to('#', url('/view/...')) }}$password', + 'viewLink': '{{ link_to('#', auth()->user()->account->getBaseUrl() . '/...') }}$password', 'viewButton': isQuote || (invoice && invoice.invoice_type_id == {{ INVOICE_TYPE_QUOTE }}) ? '{!! Form::flatButton('view_quote', '#0b4d78') !!}$password' : '{!! Form::flatButton('view_invoice', '#0b4d78') !!}$password', - 'paymentLink': '{{ link_to('#', url('/payment/...')) }}$password', + 'paymentLink': '{{ link_to('#', auth()->user()->account->getBaseUrl() . '/...') }}$password', 'paymentButton': '{!! Form::flatButton('pay_now', '#36c157') !!}$password', 'autoBill': '{{ trans('texts.auto_bill_notification_placeholder') }}', - 'portalLink': "{{ URL::to('/client/portal/...') }}", + 'portalLink': "{{ auth()->user()->account->getBaseUrl() . '/...' }}", 'portalButton': '{!! Form::flatButton('view_portal', '#36c157') !!}', 'customClient1': invoice ? invoice.client.custom_value1 : 'custom value', 'customClient2': invoice ? invoice.client.custom_value2 : 'custom value', @@ -53,7 +53,7 @@ // Add any available payment method links @foreach (\App\Models\Gateway::$gatewayTypes as $type) @if ($type != GATEWAY_TYPE_TOKEN) - {!! "keys['" . Utils::toCamelCase(\App\Models\GatewayType::getAliasFromId($type)) . "Link'] = '" . URL::to('/payment/...') . "';" !!} + {!! "keys['" . Utils::toCamelCase(\App\Models\GatewayType::getAliasFromId($type)) . "Link'] = '" . auth()->user()->account->getBaseUrl() . "/...';" !!} {!! "keys['" . Utils::toCamelCase(\App\Models\GatewayType::getAliasFromId($type)) . "Button'] = '" . Form::flatButton('pay_now', '#36c157') . "';" !!} @endif @endforeach