<?php

namespace App\Models;

use App\Libs\Database\Eloquent\ContentTypeModel;
use App\Models\GenericBackoffice\Traits\LanguageSupportTrait;
use MatanYadaev\EloquentSpatial\Objects\Point;

class Occasion extends ContentTypeModel
{
    use LanguageSupportTrait;

    protected $hidden = ['languages', "websites"];
    protected $with = ['languages', "websites"];
    protected $dates = ['date']; // dates
    protected $casts = [
        'location' => Point::class
    ];

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

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

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