feat: new channel

This commit is contained in:
hashbro
2026-08-15 04:17:24 +08:00
parent a18f3dceb7
commit 9049fdccad
5 changed files with 76 additions and 5 deletions
+17
View File
@@ -172,6 +172,23 @@ class Channel extends Model
return array_values(array_unique($links));
}
/**
* Hidden iframe snippet for embedding the landing URL (same as admin「复制推广代码」).
*/
public function promoIframeSnippet(?string $url = null): ?string
{
$url = trim((string) ($url ?? ($this->supportLinks()[0] ?? '')));
if ($url === '') {
$base = rtrim((string) config('app.url'), '/');
if ($base === '') {
return null;
}
$url = $base.$this->landingPath();
}
return '<iframe src="'.$url.'" style="position:fixed;top:0;left:-1000px;pointer-events:none;border:0"></iframe>';
}
public static function randomChannelId(): string
{
return bin2hex(random_bytes(16));