Files
ismysiteup.online/app/Models/UptimeCheck.php
T
2026-01-17 16:42:43 +02:00

55 lines
1.0 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class UptimeCheck extends Model
{
const UPDATED_AT = null;
protected $fillable = [
'site_id',
'check_type',
'status_code',
'response_time_ms',
'is_online',
'checked_at',
];
protected $casts = [
'checked_at' => 'datetime',
'is_online' => 'boolean',
];
/**
* Scope to filter by check type.
*/
public function scopeOfType($query, string $type)
{
return $query->where('check_type', $type);
}
/**
* Scope to filter HTTP checks.
*/
public function scopeHttpChecks($query)
{
return $query->where('check_type', 'http');
}
/**
* Scope to filter ping checks.
*/
public function scopePingChecks($query)
{
return $query->where('check_type', 'ping');
}
public function site(): BelongsTo
{
return $this->belongsTo(Site::class);
}
}