feat: add sub category deep link
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user