<?php

    namespace App\Models\GenericBackoffice;

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

    class Entry extends ContentTypeModel
    {
        use LanguageSupportTrait;

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

        protected $fillable = [
            'title',
            'slug',
            'lang_slug',
            'content',
            'status',
            'password_protected',
        ];

        protected $dates = [];
        protected $spatialFields = [];

        protected $casts = [];

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

        public function blocks() {
            return $this->belongsToMany(Block::class, 'entry_block')->withPivot('position');
        }

    }
