<?php

    namespace App\Models;

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

    class Footer extends ContentTypeModel
    {
        use LanguageSupportTrait;

        protected $table = 'footer';

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

        protected $dates = []; // dates

        protected $casts = ['data' => 'array'];

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

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

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

        public function imageLinks() {
            return $this->belongsToMany(ImageLink::class);
        }

        public function scopeIsActive($query) {
            return $query->where('is_active', 1);
        }
    }
