<?php

namespace App\Models\Shop;

use Dyrynda\Database\Support\CascadeSoftDeletes;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;

class TagGroup extends Model
{
    use CascadeSoftDeletes, SoftDeletes;

    protected $guarded = ['id'];

    protected $table = 'tag_groups';

    protected $cascadeDeletes = ['tags'];

    public function tags(): HasMany
    {
        return $this->hasMany(Tag::class);
    }

    public function article_family(): BelongsTo
    {
        return $this->belongsTo(ArticleNature::class);
    }

    public function scopeVisible($query)
    {
        return $query->where('visible', 1);
    }
}
