feat: deep link added

This commit is contained in:
2026-09-02 10:30:02 +03:30
parent 3f3b5b1d69
commit a3cda12560
9 changed files with 256 additions and 11 deletions
+19 -1
View File
@@ -21,7 +21,12 @@ class Media extends Model
'external_url',
'duration',
'visibility',
'is_premium'
'is_premium',
'is_deeplink_only'
];
protected $casts = [
'is_deeplink_only' => 'boolean',
];
protected $appends = [
'average_rating',
@@ -37,6 +42,7 @@ class Media extends Model
'is_liked',
'likes_count',
'url',
'deep_link',
];
public function image()
{
@@ -89,6 +95,18 @@ public function getUrlAttribute()
return $this->external_url;
}
// Public deep link for this media (canonical aramejan.com form).
public function getDeepLinkAttribute(): ?string
{
$canonical = config('deeplinks.media_pattern');
if ($canonical) {
return rtrim(str_replace('{id}', $this->id, $canonical), '/');
}
return url('/media/' . $this->id);
}
// is_saved / saved_count come from the HasSaves trait (saved_items table),
// so the /saves/* endpoints and the media list/show all agree.
}