Skip to content

Conversation

@syofyanzuhad
Copy link

__clone method called on non-object

70         $this->uptimeCheckFailed($reason);
71     }
72 
73     public function uptimeCheckSucceeded(): void
74     {
75         $this->uptime_status = UptimeStatus::UP;
76         $this->uptime_check_failure_reason = '';
77 
78         $wasFailing = ! is_null($this->uptime_check_failed_event_fired_on_date);
79         $lastStatusChangeDate = $this->uptime_status_last_change_date ? clone $this->uptime_status_last_change_date :null;
80 
81         $this->uptime_check_times_failed_in_a_row = 0;
82         $this->uptime_last_check_date = Carbon::now();
83         $this->uptime_check_failed_event_fired_on_date = null;
84         $this->save();
85 
86         if ($wasFailing) {
87             $downtimePeriod = new Period($lastStatusChangeDate, $this->uptime_last_check_date);
88 
89             event(new UptimeCheckRecovered($this, $downtimePeriod));

image

@syofyanzuhad
Copy link
Author

syofyanzuhad commented Jun 9, 2025

It's fixed with adding cast to the uptime_status_last_change_date column on monitoring custom model

<?php

namespace App\Models;

use Spatie\UptimeMonitor\Models\Monitor as SpatieMonitor;

class Monitor extends SpatieMonitor
{
    protected $casts = [
        'uptime_check_enabled' => 'boolean',
        'certificate_check_enabled' => 'boolean',
        'uptime_last_check_date' => 'datetime',
        'uptime_status_last_change_date' => 'datetime',
        'uptime_check_failed_event_fired_on_date' => 'datetime',
        'certificate_expiration_date' => 'datetime',
    ];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant