Skip to content
Snippets Groups Projects
Commit e32e0c43 authored by Thibault Debatty's avatar Thibault Debatty
Browse files

json : encode status color and last record time

parent 68e5813f
No related branches found
No related tags found
No related merge requests found
Pipeline #13266 passed
......@@ -39,7 +39,7 @@ class Server extends Model
// add attributes when serializing to json
// https://laravel.com/docs/8.x/eloquent-serialization#appending-values-to-json
protected $appends = ['url', 'status', 'failing_sensors'];
protected $appends = ['url', 'status', 'failing_sensors', 'last_record_time'];
public function getUrlAttribute() : string
{
......@@ -62,6 +62,10 @@ class Server extends Model
return $failing_sensors;
}
public function getLastRecordTime() : int
{
return $this->info()->lastRecordTime()->timestamp;
}
/**
......
......@@ -37,7 +37,8 @@ class Status
{
return [
"code" => $this->code,
"name" => $this->__toString()];
"name" => $this->__toString(),
"color" => $this->color()];
}
public function code() : int
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment