<?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\SoftDeletes;

class SslCertificate extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = [
        'common_name', 'san', 'issuer', 'algorithm',
        'valid_from', 'valid_until', 'days_remaining',
        'status', 'grade', 'auto_renew', 'last_checked_at', 'website_id',
    ];

    protected $casts = [
        'san' => 'array',
        'valid_from' => 'datetime',
        'valid_until' => 'datetime',
        'last_checked_at' => 'datetime',
        'auto_renew' => 'boolean',
    ];

    public function website(): BelongsTo
    {
        return $this->belongsTo(Website::class);
    }
}
