feat: add sub category deep link

This commit is contained in:
2026-09-03 10:57:02 +03:30
parent ebe5f50145
commit 7b888f111e
6 changed files with 102 additions and 2 deletions
+18 -1
View File
@@ -10,7 +10,24 @@ class SubCategory extends Model
{
protected $table = 'sub_categories';
protected $fillable = ['category_id', 'name', 'description'];
protected $fillable = ['category_id', 'name', 'description', 'is_deeplink_only'];
protected $casts = [
'is_deeplink_only' => 'boolean',
];
protected $appends = ['deep_link'];
public function getDeepLinkAttribute(): ?string
{
$canonical = config('deeplinks.subcategory_pattern');
if ($canonical) {
return rtrim(str_replace('{id}', $this->id, $canonical), '/');
}
return url('/subcategory/' . $this->id);
}
public function category(): BelongsTo
{