<?php

namespace App\Models;

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

class Subscription extends Model
{
    use HasFactory;
    use softDeletes;

    protected $fillable = ['title','type','stripe_price_id','price', 'duration', 'headline', 'user_allowed','subject_allowed','mark_featured'];
    
    protected $casts = [
        'mark_featured' => 'integer',
    ];

    public function features()
    {
        return $this->belongsToMany(Feature::class, 'subscription_features');
    }
    
    public function orders()
    {
        return $this->hasMany(Order::class, 'subscription_id');
    }
    public function userSubscription()
    {
        return $this->hasOne(UserSubscription::class, 'subscription_id');
    }
}
