Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add raw_url attribute to serialization #175

Merged
merged 2 commits into from
May 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Models/Monitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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();
Expand Down
9 changes: 9 additions & 0 deletions tests/Integration/Models/MonitorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']
);
}
}