<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Subscription extends Model
{
    use HasFactory;

    protected $fillable = [
        'name',
        'causal_id',
        'sub_causal_id',
        'subscription_price',
        'prices',
        'enabled'
    ];

    public function getCount()
    {
        return \App\Models\MemberSubscription::where('subscription_id', $this->id)->count();
    }

    public function getCausal()
    {
        return $this->belongsTo(CourseSubscription::class);
    }

    public function getSubscriptionCausal()
    {
        return $this->belongsTo(CourseSubscription::class, 'sub_causal_id');
    }
}
