<?php

namespace Modules\Cms\Models;

use App\Models\Model;
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
use Illuminate\Database\Eloquent\SoftDeletes;

class Tag extends Model
{

    use Cachable,
        SoftDeletes;

    protected $table = 'cms_tags';

    /**
     * 不参与版本记录的字段
     * @var array|string[]
     */
    protected array $dontVersionable = ['updated_at'];

    public function articles(): MorphToMany
    {
        return $this->morphedByMany(Article::class, 'taggable', 'cms_taggable');
    }

    public function pages(): MorphToMany
    {
        return $this->morphedByMany(Page::class, 'taggable', 'cms_taggable');
    }

}