<?php

namespace App\Models;

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

class Theme extends ContentTypeModel
{
    use LanguageSupportTrait;

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

    protected $fillable = [
        'external_id',
        'parent_id',
    ];

    public function icon()
    {
        return $this->belongsTo(MediaItem::class);
    }
/*
    public function childrens()
    {
        return $this->hasMany(Theme::class, 'parent_id', 'external_id');
    }
*/
    public function epigraphs()
    {
        return $this->belongsToMany(Epigraph::class)->withPivot('position')->withTimestamps();
    }

    public function properties()
    {
        return $this->belongsToMany(Property::class)->withPivot('position')->withTimestamps();
    }

    public function documents()
    {
        return $this->belongsToMany(Document::class)->withPivot('position')->withTimestamps();
    }
}
