Merge pull request #6641 from beganovich/v5-684

Fixes for company website on login page
This commit is contained in:
David Bomba 2021-09-14 20:16:28 +10:00 committed by GitHub
commit 5b33546e46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 3 deletions

View File

@ -12,6 +12,7 @@
namespace App\Models\Presenters; namespace App\Models\Presenters;
use App\Models\Country; use App\Models\Country;
use Illuminate\Support\Str;
/** /**
* Class CompanyPresenter. * Class CompanyPresenter.
@ -139,4 +140,24 @@ class CompanyPresenter extends EntityPresenter
{ {
return $this->entity->size ? $this->entity->size->name : ''; return $this->entity->size ? $this->entity->size->name : '';
} }
/**
* Return company website URL.
*
* @return string
*/
public function website(): string
{
$website = $this->entity->getSetting('website');
if (empty($website)) {
return $website;
}
if (Str::contains($website, ['http', 'https'])) {
return $website;
}
return \sprintf('http://%s', $website);
}
} }

View File

@ -77,10 +77,10 @@
</div> </div>
@endif @endif
@if(!is_null($company) && !empty($company->getSetting('website'))) @if(!empty($company->present()->website()))
<div class="mt-5 text-center"> <div class="mt-5 text-center">
<a class="button-link text-sm" href="{{ $company->getSetting('website') }}"> <a class="button-link text-sm" href="{{ $company->present()->website() }}">
{{ ctrans('texts.back_to', ['url' => parse_url($company->getSetting('website'))['host'] ?? $company->getSetting('website') ]) }} {{ ctrans('texts.back_to', ['url' => parse_url($company->present()->website())['host'] ?? $company->present()->website() ]) }}
</a> </a>
</div> </div>
@endif @endif