<?php

namespace App\Models;

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

class SubscriptionMember extends Model
{
    use HasFactory;

    protected $fillable = [
        'shared_subscription_id',
        'user_id',
        'slots_taken',
        'subscription_amount',
        'platform_fee',
        'owner_connection_fee',
        'status',
        'payment_verified',
        'joined_at',
        'expires_at',
        'cancel_requested_at',
    ];

    protected $casts = [
        'subscription_amount' => 'decimal:2',
        'platform_fee' => 'decimal:2',
        'owner_connection_fee' => 'decimal:2',
        'payment_verified' => 'boolean',
        'joined_at' => 'datetime',
        'expires_at' => 'datetime',
        'cancel_requested_at' => 'datetime',
    ];

    public function sharedSubscription()
    {
        return $this->belongsTo(SharedSubscription::class);
    }

    public function user()
    {
        return $this->belongsTo(User::class);
    }
}
