feat: deep link added
This commit is contained in:
+14
-2
@@ -16,19 +16,31 @@ class Category extends Model
|
||||
self::TYPE_BREATHING_TEMPLATE,
|
||||
];
|
||||
|
||||
protected $fillable = ['name', 'type', 'order', 'description', 'icon'];
|
||||
protected $fillable = ['name', 'type', 'order', 'description', 'icon', 'is_deeplink_only'];
|
||||
|
||||
protected $casts = [
|
||||
'order' => 'integer',
|
||||
'is_deeplink_only' => 'boolean',
|
||||
];
|
||||
|
||||
protected $appends = ['icon_url'];
|
||||
protected $appends = ['icon_url', 'deep_link'];
|
||||
|
||||
public function getIconUrlAttribute(): ?string
|
||||
{
|
||||
return $this->icon ? asset('storage/' . $this->icon) : null;
|
||||
}
|
||||
|
||||
public function getDeepLinkAttribute(): ?string
|
||||
{
|
||||
$canonical = config('deeplinks.category_pattern');
|
||||
|
||||
if ($canonical) {
|
||||
return rtrim(str_replace('{id}', $this->id, $canonical), '/');
|
||||
}
|
||||
|
||||
return url('/category/' . $this->id);
|
||||
}
|
||||
|
||||
public function questions()
|
||||
{
|
||||
return $this->hasMany(Question::class);
|
||||
|
||||
Reference in New Issue
Block a user