<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;

class Subscription extends Model
{
    use HasFactory;
protected $with = ["plan"];
    protected $fillable = [
        'plan_id',
        'subscription_duration',
        'status',
        'amount',
        'organisation_id',
        'start_date',
        'end_date',
        'next_billing_date',
        'is_active'
    ];


    //Define child relationships
    public function organisation() : BelongsTo {
        return $this->belongsTo(Organisation::class);
    }
    public function plan() : BelongsTo {
        return $this->belongsTo(Plan::class);
    }
    public function subcriptionTransaction() : HasOne {
        return $this->hasOne(SubscriptionTransactions::class);
    }
}
