<?php

    namespace App\Models;

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

    class Project extends ContentTypeModel
    {
        use LanguageSupportTrait;

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

        protected $dates = []; // dates

        protected $casts = [
            'authors' => 'array',
            'block_title' => 'array',
        ];

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

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

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

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

        public function authors() {
            return $this->belongsToMany(WebLink::class, 'project_web_link', 'project_id', 'web_link_id')->withPivot('position')->withTimestamps();
        }
    }
