feat: deep link added
This commit is contained in:
+19
-1
@@ -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.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user