<?php

namespace Modules\Settings\Models\Traits;

use Illuminate\Database\Eloquent\Relations\MorphMany;
use Modules\Settings\Models\Attachment;

trait HasAttachments
{
    public function attachments(): MorphMany
    {
        return $this->morphMany(Attachment::class, 'attachable');
    }

    public function visibleAttachments(): MorphMany
    {
        return $this->morphMany(Attachment::class, 'attachable')
            ->where('is_visible', true);
    }

    public function hiddenAttachments(): MorphMany
    {
        return $this->morphMany(Attachment::class, 'attachable')
            ->where('is_visible', false);
    }
}
