Skip to content

Commit

Permalink
fix local asset as badge url on config
Browse files Browse the repository at this point in the history
  • Loading branch information
d8vjork committed May 14, 2024
1 parent 0f63009 commit 453ac47
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 2 additions & 4 deletions config/companion.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
*
* Add {region} in case you want to manage multiple badges across multiple regions (locales).
*
* Static badge url: asset('app_store_badge.svg')
* Using Laravel helper functions: asset('app_store/{region}/black_badge.svg')
* Static URL (from public/ folder): 'app_store/{region}/black_badge.svg'
* Or just a string as external img: https://cdn.my_host.com/app_store/{region}/black_badge.svg
*/
'apple_badge_url' => 'https://developer.apple.com/assets/elements/badges/download-on-the-app-store.svg',
Expand All @@ -56,8 +55,7 @@
*
* Add {region} in case you want to manage multiple badges across multiple regions (locales).
*
* Static badge url: asset('play_store_badge.svg')
* Using Laravel helper functions: asset('play_store/{region}/black_badge.svg')
* Static URL (from public/ folder): 'play_store/{region}/black_badge.svg'
* Or just a string as external img: https://cdn.my_host.com/play_store/{region}/black_badge.svg
*/
'android_badge_url' => 'https://play.google.com/intl/en_us/badges/static/images/badges/{region}_badge_web_generic.png',
Expand Down
7 changes: 6 additions & 1 deletion src/CompanionApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use chillerlan\QRCode\QRCode;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Str;

class CompanionApplication
{
Expand Down Expand Up @@ -144,6 +145,10 @@ public function getStoreBadgeImgUrl(): string
/** @var string $appStoreBadgeUrl */
$appStoreBadgeUrl = config("companion.store.{$platform}_badge_url");

if (Str::startsWith($appStoreBadgeUrl, 'http')) {
$appStoreBadgeUrl = asset($appStoreBadgeUrl);
}

return str_replace('{region}', $this->storeRegion(), $appStoreBadgeUrl);
}

Expand Down Expand Up @@ -171,7 +176,7 @@ public function getStoreBadgeHtml(int $width = 180, string $alt = ''): string
/**
* Get application store link as QR code.
*/
public function getStoreQrCode(): string
public function getStoreQrCode()
{
return (new QRCode())->render($this->getStoreLink());
}
Expand Down

0 comments on commit 453ac47

Please sign in to comment.