<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Spatie\UptimeMonitor\Models\Monitor;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class LicenseDomain extends Model
{
    use HasFactory , SoftDeletes;
    protected $dates = ['deleted_at'];
    protected $fillable = [
        'license_id',
        'domain',
        'status',
        'added_at',
        'last_used_at'
    ];

    protected $casts = [
        'license_id' => 'integer',
        'added_at' => 'datetime',
        'last_used_at' => 'datetime',
    ];

    public function license()
    {
        return $this->belongsTo(License::class);
    }

    public function monitor()
    {
        return $this->hasOne(
            \Spatie\UptimeMonitor\Models\Monitor::class,
            'url',
            'domain'
        );
    }

}
