<?php

    namespace App\Models;

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

    class PropertyType extends ContentTypeModel
    {

        CONST TYPE_DISCOVERY_PLACE          = 10;
        CONST TYPE_MUSEUM                   = 136;
        CONST TYPE_ARCHEOLOGICAL_SITE       = 135;
        CONST TYPE_MUSEALIZED_SITE          = 138;
        
        use LanguageSupportTrait;

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

        protected $fillable = [
            'external_id',
        ];

        public function property() {
            return $this->hasOne(Property::class);
        }

        public function scopePropertyTypeFilters($query) {
            return $query->whereIn('external_id', [
                self::TYPE_ARCHEOLOGICAL_SITE,
                self::TYPE_MUSEUM,
                self::TYPE_MUSEALIZED_SITE,
                self::TYPE_DISCOVERY_PLACE,
            ]);
        }

        public function isMuseum() {
            return $this->external_id === self::TYPE_MUSEUM;
        }
        public function isArcheologicalSite() {
            return $this->external_id === self::TYPE_ARCHEOLOGICAL_SITE;
        }
        public function isDiscoveryPlace() {
            return $this->external_id === self::TYPE_DISCOVERY_PLACE;
        }
        public function isMusealizedSite() {
            return $this->external_id === self::TYPE_MUSEALIZED_SITE;
        }
    }
