31 lines
589 B
PHP
31 lines
589 B
PHP
<?php
|
|
|
|
namespace App\Facades;
|
|
|
|
use Illuminate\Support\Facades\Facade;
|
|
|
|
/**
|
|
* @method static string url(string $ip)
|
|
*/
|
|
class BaseHelperFacade extends Facade
|
|
{
|
|
protected static function getFacadeAccessor(): string
|
|
{
|
|
return 'base-helper';
|
|
}
|
|
|
|
/**
|
|
* Build a base HTTPS URL from an IP address or hostname.
|
|
*/
|
|
public static function url(string $ip): string
|
|
{
|
|
$ip = rtrim($ip, '/');
|
|
|
|
if (!str_starts_with($ip, 'http://') && !str_starts_with($ip, 'https://')) {
|
|
return 'https://' . $ip;
|
|
}
|
|
|
|
return $ip;
|
|
}
|
|
}
|