<?php

namespace App\Models;

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

/**
 * A SaaS pricing tier — what a company pays ABIC_E-Learning for its
 * account. Managed only from the SaaS control panel (add/edit/delete).
 * Unrelated to Plan, which prices course bundles for students.
 */
class SubscriptionPlan extends Model
{
    use HasFactory;

    protected $guarded = ['id'];

    protected $casts = [
        'price' => 'decimal:2',
        'custom_domain_allowed' => 'boolean',
    ];

    public function companySubscriptions(): HasMany
    {
        return $this->hasMany(CompanySubscription::class);
    }

    public function isActive(): bool
    {
        return $this->status === 'active';
    }
}
