<?php

namespace App\Models\Backoffice;

use App\Models\Backoffice\Support\ContentTypeModel;
use App\Models\Backoffice\Traits\LanguageSupportTrait;

class Page extends ContentTypeModel
{
    use LanguageSupportTrait;

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

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

    protected $casts = [];

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

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

    public function repeaterBlocks() {
        return $this->hasMany(RepeaterBlock::class);
    }

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