<?php

namespace App\Models\Finance;

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

class Subscription extends Model
{
    use SoftDeletes;

    protected $table = 'subscriptions';

    protected $fillable = [
        'tenant_id', 'customer', 'plan', 'monthly_fee', 'billing_cycle',
        'start_date', 'next_billing', 'status', 'users', 'memo',
    ];

    protected $casts = [
        'monthly_fee' => 'integer',
        'users' => 'integer',
        'start_date' => 'date',
        'next_billing' => 'date',
    ];

    public function scopeForTenant($query, $tenantId)
    {
        return $query->where('tenant_id', $tenantId);
    }
}
