<?php

namespace App\Models;

use App\Libs\Database\Eloquent\ContentTypeModel;
use App\Models\GenericBackoffice\Traits\LanguageSupportTrait;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use App\Traits\Indexable;
use App\Traits\FcmSubscribable;


class NewsItem extends ContentTypeModel
{
    use LanguageSupportTrait;
    use Indexable;
    use FcmSubscribable;

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


    /**
     * Get the associated image
     *
     * @return BelongsTo
     */
    public function image(): BelongsTo
    {
        return $this->belongsTo(MediaItem::class);
    }

    /**
     * gets the associated category
     *
     * @return BelongsTo
     */
    public function category(): BelongsTo
    {
        return $this->belongsTo(NewsCategory::class, 'news_category_id');
    }

    public function artists()
    {
        return $this->belongsToMany(Artist::class);
    }
}
