<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * Ein Kauf, dessen Zahlung Tage später geplatzt ist — siehe die Migration.
 */
class FailedCheckout extends Model
{
    protected $fillable = [
        'stripe_session_id', 'email', 'name', 'plan',
        'amount_cents', 'currency', 'failed_at', 'resolved_at', 'note',
    ];

    protected function casts(): array
    {
        return [
            'amount_cents' => 'integer',
            'failed_at' => 'datetime',
            'resolved_at' => 'datetime',
        ];
    }

    public function isOpen(): bool
    {
        return $this->resolved_at === null;
    }
}
