<?php

    namespace App\Models;

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

    class Tutorial extends ContentTypeModel
    {
        use LanguageSupportTrait;

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

        protected $dates = [];
        protected $spatialFields = [];

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

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

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

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