<?php

namespace App\Models;

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

class Location extends ContentTypeModel
{
    use LanguageSupportTrait;
    use HasSpatial;
    use FcmSubscribable;
    use Indexable;

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

    protected $dates = []; // dates
    protected $casts = [
        'map_position' => Point::class
    ];

    public function city()
    {
        return $this->belongsTo(City::class);
    }

    public function cityZone()
    {
        return $this->belongsTo(CityZone::class);
    }

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

    public function exhibitions()
    {
        return $this->hasMany(Exhibition::class);
    }

    /**
     * Get all of the tags for the exhibition.
     */
    public function tags()
    {
        return $this->morphToMany(Tag::class, 'taggable');
    }
}
