<?php

namespace App\Models;

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

class Occasion extends ContentTypeModel
{
    use LanguageSupportTrait, SpatialTrait;

    protected $hidden = ['languages', "websites"];
    protected $with = ['languages', "websites"];
    protected $dates = ['date']; // dates
    protected $spatialFields = ['location'];

    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();
    }
}
