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
+14 -2
View File
@@ -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);