diff --git a/src/Models/Monitor.php b/src/Models/Monitor.php index 48fa3829..5774e9b9 100644 --- a/src/Models/Monitor.php +++ b/src/Models/Monitor.php @@ -19,6 +19,8 @@ class Monitor extends Model protected $guarded = []; + protected $appends = ['raw_url']; + protected $dates = [ 'uptime_last_check_date', 'uptime_status_last_change_date', @@ -62,6 +64,14 @@ public function getUrlAttribute() return Url::fromString($this->attributes['url']); } + /** + * @return string + */ + public function getRawUrlAttribute() + { + return (string) $this->url; + } + public static function boot() { parent::boot(); diff --git a/tests/Integration/Models/MonitorTest.php b/tests/Integration/Models/MonitorTest.php index 88f119c9..dd4d0d70 100644 --- a/tests/Integration/Models/MonitorTest.php +++ b/tests/Integration/Models/MonitorTest.php @@ -61,4 +61,13 @@ public function it_can_disable_and_enable_itself_for_an_http_url() //it will not enable the certificate check for a non-https site. $this->assertFalse($this->monitor->certificate_check_enabled); } + + /** @test */ + public function raw_url_is_appended_during_serialization() + { + $this->assertEquals( + 'http://mysite.com', + $this->monitor->toArray()['raw_url'] + ); + } }