<?php

namespace App\Models;

use App\Libs\Database\Eloquent\ContentTypeModel;
use App\Models\GenericBackoffice\Traits\LanguageSupportTrait;

class Document extends ContentTypeModel
{
    use LanguageSupportTrait;

    protected $hidden = ['languages', "websites"];
    protected $with = ['languages', "websites"];

    public function image() {
        return $this->belongsTo(MediaItem::class);
    }

    public function documentFile() {
        return $this->belongsTo(MediaItem::class);
    }

    public function documentType() {
        return $this->belongsTo(DocumentType::class);
    }

    public function topics() {
        return $this->belongsToMany(Topic::class)->withPivot('position');
    }

    public function tags() {
        return $this->belongsToMany(Tag::class)->withPivot('position');
    }

    public function country() {
        return $this->belongsTo(Country::class);
    }
}
