<?php

namespace App\Models;

use App\Models\Backoffice\Support\ContentTypeModel;
use App\Models\Backoffice\Traits\LanguageSupportTrait;

class SubPlan extends ContentTypeModel
{
    use LanguageSupportTrait;

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

    protected $casts = [
        'is_highlighted' => 'boolean',
        'is_basic_plan' => 'boolean',
    ];

    public function subPlanOptions()
    {
        return $this->hasMany(SubPlanOption::class);
    }

    public function subPlanFeatures()
    {
        return $this->hasMany(SubPlanFeature::class)->orderBy('position');
    }

    public function signSubPlanFeatures()
    {
        return $this->hasMany(SignSubPlanFeature::class)->orderBy('position');
    }

    public function subscriptionRewards()
    {
        return $this->belongsToMany(\App\Models\SubscriptionReward::class, 'sub_plan_subscription_reward')
            ->withPivot('position')
            ->orderBy('position');
    }

    public function subscriptionPlan()
    {
        return $this->belongsTo(SubscriptionPlan::class);
    }
}
